The self-hosted runner builds on the Pi5 alongside live services; the unthrottled build saturated all cores (Go compiler + esbuild) and took the reverse-proxied sites down. Add BUILD_CPUS build-arg → GOMAXPROCS in both build stages (caps the Go compiler and Vite's esbuild) and go build -p, plus nice/ionice on the build. Slower build, responsive host. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
41 lines
1.5 KiB
YAML
41 lines
1.5 KiB
YAML
name: build-and-push
|
|
|
|
# Bygger Archivum-imagen på Pi5-runnern (arm64, nativt) och pushar till den lokala
|
|
# registryn. Ett enda multi-stage-bygge (frontend -> backend -> runtime), så
|
|
# build-context måste vara repo-roten (Dockerfile COPY:ar frontend/, backend/ och
|
|
# docker/entrypoint.sh). localhost:5000 trustas automatiskt av Docker på Pi5
|
|
# (ingen insecure-registry-config behövs där).
|
|
#
|
|
# Pull:a på Pi5 med localhost:5000/archivum:latest (t.ex. i dockge-stacken).
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
paths:
|
|
- "backend/**"
|
|
- "frontend/**"
|
|
- "docker/**"
|
|
- ".gitea/workflows/build.yaml"
|
|
workflow_dispatch: {}
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build & push image
|
|
# The runner builds on the Pi5 next to live services. BUILD_CPUS caps the
|
|
# CPU-heavy build tools (Go compiler + esbuild) to 2 of 4 cores so the box
|
|
# stays responsive; nice/ionice further deprioritise the client-side work.
|
|
# Slower build, but nginx/NPM and the other containers keep serving.
|
|
run: |
|
|
nice -n 19 ionice -c 3 docker build --progress=plain \
|
|
--build-arg BUILD_CPUS=2 \
|
|
-f docker/Dockerfile \
|
|
-t localhost:5000/archivum:latest \
|
|
-t "localhost:5000/archivum:${GITHUB_SHA::12}" \
|
|
.
|
|
docker push localhost:5000/archivum:latest
|
|
docker push "localhost:5000/archivum:${GITHUB_SHA::12}"
|