Skip to content

Build Docker Image

Build Docker Image #1

Workflow file for this run

name: Build Docker Image
on:
release:
types:
- created
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
env:
cache-name: npm-cache
with:
path: "web/node_modules"
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Set release version
run: |
echo "Release version ${GITHUB_REF#refs/*/v}"
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
x1unix/springboard
ghcr.io/${{ github.repository }}/springboard
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- uses: actions/setup-node@v4
with:
node-version: "${{env.NODE_VERSION}}"
- run: |
npm ci --silent && npm run build && rm -rf build/config
working-directory: .
env:
NODE_ENV: "production"
REACT_APP_VERSION: "${{ env.RELEASE_VERSION }}"
REACT_APP_GITHUB_URL: "${{ github.server_url }}/${{ github.repository }}"
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ./ci.dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
- name: Print image digest
run: echo ${{ steps.docker_build.outputs.digest }}