Add targetplatform to Dockerfile #23
This file contains 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: Create Images | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
REGISTRY: ghcr.io | |
OWNER: ${{ github.repository_owner }} | |
API_IMAGE: openwish-api | |
WEB_IMAGE: openwish-web | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Docker metadata for API | |
id: meta-api | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.API_IMAGE }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=sha,format=short | |
type=ref,event=branch | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Build and push API image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./src | |
file: ./src/OpenWish.ApiService/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-api.outputs.tags }} | |
labels: ${{ steps.meta-api.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Generate Docker metadata for Web | |
id: meta-web | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.WEB_IMAGE }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=sha,format=short | |
type=ref,event=branch | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Build and push Web image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./src | |
file: ./src/OpenWish.Web/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-web.outputs.tags }} | |
labels: ${{ steps.meta-web.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |