-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (51 loc) · 1.85 KB
/
Dockerfile
File metadata and controls
55 lines (51 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Multi-stage build for the Becoming app
# Stage 1: Build frontend
FROM node:22-alpine AS frontend
WORKDIR /app/frontend
COPY scripts/becoming/frontend/package*.json ./
RUN npm ci
COPY scripts/becoming/frontend/ ./
RUN npm run build
# Stage 2: Download scriptures for memorization lookup
# Uses the gospel-library downloader to fetch standard works (~20MB)
FROM golang:1.25-alpine AS scriptures
RUN apk add --no-cache git
WORKDIR /dl
COPY scripts/gospel-library/go.mod scripts/gospel-library/go.sum ./
RUN go mod download
COPY scripts/gospel-library/ ./
RUN CGO_ENABLED=0 go build -o /downloader ./cmd/gospel-downloader/
RUN /downloader -standard -output /gospel-library
# Stage 3: Extract git metadata from build context
FROM alpine:3.21 AS gitinfo
RUN apk add --no-cache git
WORKDIR /repo
COPY .git .git
RUN git rev-parse --short HEAD > /commit_hash && \
git log -1 --format=%s > /commit_msg
# Stage 4: Build Go binary
FROM golang:1.25-alpine AS backend
WORKDIR /app
COPY scripts/becoming/go.mod scripts/becoming/go.sum ./
RUN go mod download
COPY scripts/becoming/ ./
# Copy frontend dist into embed location
COPY --from=frontend /app/frontend/dist ./cmd/server/dist/
# Git metadata from build context (auto-detected, no build args needed)
COPY --from=gitinfo /commit_hash /commit_msg /tmp/
ARG VERSION=dev
ARG RELEASE_NOTES=""
RUN COMMIT=$(cat /tmp/commit_hash) && \
MSG=$(cat /tmp/commit_msg) && \
NOTES="${RELEASE_NOTES:-$MSG}" && \
CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w -X main.Version=${VERSION} -X main.CommitHash=${COMMIT} -X 'main.ReleaseNotes=${NOTES}'" \
-o /server ./cmd/server/
# Stage 5: Minimal runtime
FROM alpine:3.21
RUN apk add --no-cache ca-certificates
COPY --from=backend /server /server
COPY --from=scriptures /gospel-library/eng/scriptures /scriptures
EXPOSE 8080
ENV BECOMING_SCRIPTURES=/scriptures
ENTRYPOINT ["/server"]