added configuration for platform #9
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: Build Production Image | |
on: | |
push: | |
branches: | |
- docker | |
env: | |
REGISTRY: ghcr.io | |
SERVER_IMAGE_NAME: spreehood/spree-backend | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
env: | |
APP_NAME: spree-backend | |
BASE_DOCKER_IMAGE: ruby:3.2.0 | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
steps: | |
- name: Prepare | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.SERVER_IMAGE_NAME }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
id: build | |
with: | |
context: . | |
file: ./Dockerfile.production | |
platforms: ${{ matrix.platform }} | |
push: true | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: ghcr.io/spreehood/spree-backend:latest, ghcr.io/spreehood/spree-backend:${{github.ref_name}} | |
- name: Export digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-webapp | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 |