speed up docker build: bun everywhere, buildx layer cache, tighter dockerignore
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled

Root cause of 6+ min builds: Dockerfile stage 1 ran 'npm install' with no
package-lock.json, so every build re-resolved + re-fetched the full npm tree
from scratch on a fresh runner.

- Dockerfile: replace node:22-slim+npm stage with oven/bun:1-slim; both
  stages now 'bun install --frozen-lockfile' against the tracked bun.lock;
  --mount=type=cache for the bun install cache
- workflow: switch to docker/build-push-action with registry buildcache
  (cache-from + cache-to) so layers persist across runs
- dockerignore: add .worktrees, docs, tests, tsbuildinfo so the build context
  ships less
This commit is contained in:
2026-04-13 08:00:19 +02:00
parent 9184c3991c
commit b04c8acc39
3 changed files with 33 additions and 20 deletions

View File

@@ -14,6 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Container Registry
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY" -u "${{ github.actor }}" --password-stdin
@@ -21,14 +24,13 @@ jobs:
id: meta
run: echo "version=$(jq -r .version package.json)" >> "$GITHUB_OUTPUT"
- name: Build image
run: |
docker build \
-t "$REGISTRY/$IMAGE:latest" \
-t "$REGISTRY/$IMAGE:${{ steps.meta.outputs.version }}" \
.
- name: Push image
run: |
docker push "$REGISTRY/$IMAGE:latest"
docker push "$REGISTRY/$IMAGE:${{ steps.meta.outputs.version }}"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.meta.outputs.version }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE }}:buildcache,mode=max