|
| 1 | +name: Docker image build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - v* |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-and-push-images: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + packages: write |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up QEMU for multi-arch builds |
| 23 | + uses: docker/setup-qemu-action@v3 |
| 24 | + |
| 25 | + - name: Set up Docker Buildx |
| 26 | + id: buildx |
| 27 | + uses: docker/setup-buildx-action@v3 |
| 28 | + |
| 29 | + - name: Log in to the Container registry |
| 30 | + uses: docker/login-action@v3 |
| 31 | + with: |
| 32 | + registry: ghcr.io |
| 33 | + username: ${{ github.repository_owner }} |
| 34 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + |
| 36 | + # Extract tags with suffixes for prod and worker |
| 37 | + - name: Extract metadata (tags, labels) for Docker (prod) |
| 38 | + id: meta_prod |
| 39 | + uses: docker/metadata-action@v5 |
| 40 | + with: |
| 41 | + images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} |
| 42 | + tags: | |
| 43 | + type=semver,pattern={{version}} |
| 44 | + type=semver,pattern={{major}}.{{minor}} |
| 45 | + type=semver,pattern={{major}} |
| 46 | + type=edge,branch=main |
| 47 | +
|
| 48 | + # Build and push multi-arch prod image |
| 49 | + - name: Build and push prod Docker image (Multi-Arch) |
| 50 | + uses: docker/build-push-action@v6 |
| 51 | + with: |
| 52 | + context: . |
| 53 | + file: ./Dockerfile |
| 54 | + push: true |
| 55 | + platforms: linux/amd64,linux/arm64/v8 |
| 56 | + tags: ${{ steps.meta_prod.outputs.tags }} |
| 57 | + labels: ${{ steps.meta_prod.outputs.labels }} |
| 58 | + target: prod |
0 commit comments