Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[board-server] simplify docker tags & enable multi platform builds for arm64/amd64 #2985

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- main
pull_request:
branches:
- main

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -87,6 +90,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -104,14 +112,13 @@ jobs:
context: .
file: ./packages/board-server/Dockerfile
cache-from: |
type=gha,ref=${{ needs.setup.outputs.board_server_sqlite_image_name }}
type=registry,ref=${{ needs.setup.outputs.board_server_sqlite_image_path }}
cache-to: type=gha,mode=max,ref=${{ needs.setup.outputs.board_server_sqlite_image_name }}
push: true
${{ github.event_name != 'pull_request' && format('type=gha,ref={0}', needs.setup.outputs.board_server_sqlite_image_name) || 'type=gha,scope=pr' }}
${{ github.event_name != 'pull_request' && format('type=registry,ref={0}', needs.setup.outputs.board_server_sqlite_image_path) || '' }}
cache-to: ${{ github.event_name != 'pull_request' && format('type=gha,mode=max,ref={0}', needs.setup.outputs.board_server_sqlite_image_name) || 'type=gha,mode=max,scope=pr' }}
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork }}
provenance: true
platforms: linux/amd64,linux/arm64
tags: >
${{ needs.setup.outputs.board_server_sqlite_image_path }}:${{ github.sha }},
${{ needs.setup.outputs.board_server_sqlite_image_path }}:${{ needs.setup.outputs.short_hash }},
${{ needs.setup.outputs.board_server_sqlite_image_path }}:${{ needs.setup.outputs.package_version }},
${{ needs.setup.outputs.board_server_sqlite_image_path }}:latest
build-args: |
Expand All @@ -121,6 +128,7 @@ jobs:
breadboard=.

- name: Generate artifact attestation
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ needs.setup.outputs.board_server_sqlite_image_path }}
Expand All @@ -143,6 +151,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -160,16 +173,13 @@ jobs:
context: .
file: ./packages/board-server/Dockerfile
cache-from: |
type=gha,ref=${{ needs.setup.outputs.board_server_firestore_image_name }}
type=registry,ref=${{ needs.setup.outputs.board_server_firestore_image_path }}
cache-to: |
type=gha,mode=max,ref=${{ needs.setup.outputs.board_server_firestore_image_name }}
type=registry,mode=max,ref=${{ needs.setup.outputs.board_server_firestore_image_path }}
push: true
${{ github.event_name != 'pull_request' && format('type=gha,ref={0}', needs.setup.outputs.board_server_firestore_image_name) || 'type=gha,scope=pr' }}
${{ github.event_name != 'pull_request' && format('type=registry,ref={0}', needs.setup.outputs.board_server_firestore_image_path) || '' }}
cache-to: ${{ github.event_name != 'pull_request' && format('type=gha,mode=max,ref={0}|type=registry,mode=max,ref={1}', needs.setup.outputs.board_server_firestore_image_name, needs.setup.outputs.board_server_firestore_image_path) || 'type=gha,mode=max,scope=pr' }}
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork }}
provenance: true
platforms: linux/amd64,linux/arm64
tags: >
${{ needs.setup.outputs.board_server_firestore_image_path }}:${{ github.sha }},
${{ needs.setup.outputs.board_server_firestore_image_path }}:${{ needs.setup.outputs.short_hash }},
${{ needs.setup.outputs.board_server_firestore_image_path }}:${{ needs.setup.outputs.package_version }},
${{ needs.setup.outputs.board_server_firestore_image_path }}:latest
build-args: |
Expand All @@ -179,8 +189,9 @@ jobs:
breadboard=.

- name: Generate artifact attestation
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ needs.setup.outputs.board_server_firestore_image_path }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
push-to-registry: true
11 changes: 6 additions & 5 deletions packages/board-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build stage
FROM node:20-slim AS build
wfaithfull marked this conversation as resolved.
Show resolved Hide resolved
# Use a base image that supports multiple platforms for the build stage
FROM --platform=$BUILDPLATFORM node:20 AS build

WORKDIR /build

# Copy the entire monorepo
Expand All @@ -12,8 +13,8 @@
WORKDIR /build/packages/board-server
RUN npm run build

# Production stage
FROM node:20-slim
# Use a lightweight base image for the runtime stage
FROM --platform=$TARGETPLATFORM node:20

Check warning on line 17 in packages/board-server/Dockerfile

View workflow job for this annotation

GitHub Actions / Build board server sqlite image

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

Check warning on line 17 in packages/board-server/Dockerfile

View workflow job for this annotation

GitHub Actions / Build board server firestore image

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

ARG STORAGE_BACKEND
ARG ALLOWED_ORIGINS=""
Expand All @@ -35,4 +36,4 @@
npm install -g tsx

EXPOSE 3000
CMD ["node", "dist/server/index.js", "--host=0.0.0.0" ]
CMD ["node", "dist/server/index.js", "--host=0.0.0.0"]
Loading