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).
37 lines
842 B
Docker
37 lines
842 B
Docker
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder
|
|
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
|
|
WORKDIR /src
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
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
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install --no-install-recommends -y ca-certificates tzdata \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
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
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["/usr/local/bin/prayertimes"]
|