Split Docker config for dev/prod and fix arch-agnostic builds

- Dockerfile: use --platform=$BUILDPLATFORM + ARG TARGETARCH instead of
  hardcoded GOARCH=arm64, enabling cross-compilation and native builds
  on both arm64 (M1) and amd64 (prod server)
- docker-compose.yml: rewrite for Docker Swarm — image refs, deploy
  sections, overlay network, no container_name/depends_on conditions,
  DB/Redis ports not exposed externally
- docker-compose.dev.yml: rewrite as self-contained dev compose with
  build targets, container_name, depends_on, dev-safe defaults
- Makefile: switch to docker compose v2, point dev targets at
  docker-compose.dev.yml, add docker-build-prod target
- Delete stale docker/Dockerfile (Go 1.21) and docker/docker-compose.yml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
treyt
2026-02-24 21:27:35 -06:00
parent 9f8828a503
commit f1e39f90c7
6 changed files with 274 additions and 251 deletions

View File

@@ -16,7 +16,8 @@ COPY admin/ .
RUN npm run build
# Go build stage
FROM golang:1.24-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
ARG TARGETARCH
# Install build dependencies
RUN apk add --no-cache git ca-certificates tzdata
@@ -34,10 +35,10 @@ RUN go mod download
COPY . .
# Build the API binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o /app/api ./cmd/api
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o /app/api ./cmd/api
# Build the worker binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o /app/worker ./cmd/worker
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o /app/worker ./cmd/worker
# Base runtime stage for Go services
FROM alpine:3.19 AS go-base