Skip to content

Build separate images for dev and prod #6

Build separate images for dev and prod

Build separate images for dev and prod #6

Workflow file for this run

on:
push:
tags: ["v*"]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU for cross-platform builds
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Github container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for dev image
id: meta-dev
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/dev
tags: |
type=semver,pattern=v{{ major }}
type=semver,pattern=v{{ major }}.{{ minor }}
type=semver,pattern=v{{ version }}
type=raw,value=latest,enable={{ is_default_branch }}
- name: Build dev image
uses: docker/build-push-action@v5
with:
context: .
push: true
target: dev
platforms: linux/arm64, linux/amd64
tags: ${{ steps.meta-dev.outputs.tags }}
labels: ${{ steps.meta-dev.outputs.labels }}
cache-from: type=gha
cache-to: type=gha
- name: Extract metadata for prod image
id: meta-prod
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/prod
tags: |
type=semver,pattern=v{{ major }}
type=semver,pattern=v{{ major }}.{{ minor }}
type=semver,pattern=v{{ version }}
type=raw,value=latest,enable={{ is_default_branch }}
- name: Build prod image
uses: docker/build-push-action@v5
with:
context: .
push: true
target: prod
platforms: linux/arm64, linux/amd64
tags: ${{ steps.meta-prod.outputs.tags }}
labels: ${{ steps.meta-prod.outputs.labels }}
cache-from: type=gha
cache-to: type=gha