feat(docker): Preseed cities database and fix multi-arch builds
Bake the GeoNames cities database into the image at build time instead of relying on host-mounted sqlite files, and fix the Go build stage to cross-compile for the requested target platform instead of hardcoding amd64 (was silently broken for arm64 builds).
This commit is contained in:
1 parent
dc25633f61
commit
c3bf3eca8d
2 files changed
+12
-7
No files matched your search
+12
-2
@@ -1,4 +1,7 @@
|
||||
FROM golang:1.25-bookworm AS builder
|
||||
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder
|
||||
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
@@ -6,7 +9,13 @@ COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o /out/prayertimes .
|
||||
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath -ldflags="-s -w" -o /out/prayertimes .
|
||||
|
||||
FROM --platform=$BUILDPLATFORM python:3.12-slim AS seeder
|
||||
|
||||
WORKDIR /seed
|
||||
COPY scripts/seed_cities.py .
|
||||
RUN python3 seed_cities.py --db /data/prayertimes.sqlite3
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
@@ -17,6 +26,7 @@ RUN apt-get update \
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /out/prayertimes /usr/local/bin/prayertimes
|
||||
COPY --from=seeder /data/prayertimes.sqlite3 /data/prayertimes.sqlite3
|
||||
|
||||
ENV PORT=8000
|
||||
ENV DB_PATH=/data/prayertimes.sqlite3
|
||||
|
||||
@@ -8,9 +8,4 @@ services:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
PORT: "8000"
|
||||
DB_PATH: "/data/prayertimes.sqlite3"
|
||||
volumes:
|
||||
- ./prayertimes.sqlite3:/data/prayertimes.sqlite3
|
||||
- ./prayertimes.sqlite3-wal:/data/prayertimes.sqlite3-wal
|
||||
- ./prayertimes.sqlite3-shm:/data/prayertimes.sqlite3-shm
|
||||
restart: unless-stopped
|
||||
Reference in new issue
Block a user