fixed compatibility issues #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Images | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'docker/**' | |
| - 'nginx/**' | |
| - '.github/workflows/docker-build-push.yml' | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: | |
| - dockerfile: docker/Dockerfile.migrate.nonroot | |
| image-name: migrate-nonroot | |
| context: . | |
| - dockerfile: docker/Dockerfile.openrestry | |
| image-name: openresty-base | |
| context: . | |
| - dockerfile: docker/Dockerfile.openresty.nonroot | |
| image-name: openresty-nonroot | |
| context: . | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: | | |
| image=moby/buildkit:buildx-stable-1 | |
| network=host | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image-name }} | |
| tags: | | |
| type=ref,event=tag | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ matrix.context }} | |
| file: ${{ matrix.dockerfile }} | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 | |
| builder: ${{ steps.buildx.outputs.name }} | |
| shm-size: 2g | |
| provenance: false | |
| sbom: false | |
| copy-bitnami-images: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: | |
| - source-image: bitnamilegacy/postgresql-repmgr:17.6.0-debian-12-r2 | |
| target-name: postgresql-repmgr | |
| target-tag: 17.6.0-debian-12-r2 | |
| - source-image: bitnamilegacy/pgpool:4.6.3-debian-12-r0 | |
| target-name: pgpool | |
| target-tag: 4.6.3-debian-12-r0 | |
| steps: | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Copy and push Bitnami image | |
| run: | | |
| # Pull the source image | |
| docker pull ${{ matrix.source-image }} | |
| # Tag it for our registry with specific version | |
| docker tag ${{ matrix.source-image }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.target-name }}:${{ matrix.target-tag }} | |
| # Push to our registry | |
| docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.target-name }}:${{ matrix.target-tag }} | |
| build-summary: | |
| needs: [build-and-push, copy-bitnami-images] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Build Summary | |
| run: | | |
| echo "## Docker Build Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "Built and pushed the following images:" >> $GITHUB_STEP_SUMMARY | |
| echo "- migrate-nonroot" >> $GITHUB_STEP_SUMMARY | |
| echo "- openresty-base" >> $GITHUB_STEP_SUMMARY | |
| echo "- openresty-nonroot" >> $GITHUB_STEP_SUMMARY | |
| echo "- postgresql-repmgr" >> $GITHUB_STEP_SUMMARY | |
| echo "- pgpool" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Images are available at: ghcr.io/${{ github.repository }}" >> $GITHUB_STEP_SUMMARY | |
| cleanup-untagged: | |
| needs: [build-and-push, copy-bitnami-images] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Delete untagged container images | |
| uses: actions/delete-package-versions@v5 | |
| with: | |
| package-name: '${{ github.event.repository.name }}/migrate-nonroot' | |
| package-type: 'container' | |
| min-versions-to-keep: 1 | |
| delete-only-untagged-versions: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Delete untagged openresty-base images | |
| uses: actions/delete-package-versions@v5 | |
| with: | |
| package-name: '${{ github.event.repository.name }}/openresty-base' | |
| package-type: 'container' | |
| min-versions-to-keep: 1 | |
| delete-only-untagged-versions: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Delete untagged openresty-nonroot images | |
| uses: actions/delete-package-versions@v5 | |
| with: | |
| package-name: '${{ github.event.repository.name }}/openresty-nonroot' | |
| package-type: 'container' | |
| min-versions-to-keep: 1 | |
| delete-only-untagged-versions: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Delete untagged postgresql-repmgr images | |
| uses: actions/delete-package-versions@v5 | |
| with: | |
| package-name: '${{ github.event.repository.name }}/postgresql-repmgr' | |
| package-type: 'container' | |
| min-versions-to-keep: 1 | |
| delete-only-untagged-versions: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Delete untagged pgpool images | |
| uses: actions/delete-package-versions@v5 | |
| with: | |
| package-name: '${{ github.event.repository.name }}/pgpool' | |
| package-type: 'container' | |
| min-versions-to-keep: 1 | |
| delete-only-untagged-versions: true | |
| token: ${{ secrets.GITHUB_TOKEN }} |