-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (34 loc) · 1.28 KB
/
Copy pathDockerfile
File metadata and controls
37 lines (34 loc) · 1.28 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
# syntax=docker/dockerfile:1.6
# ----- stage 1: build frontend ------------------------------------------------
# Milestone M3 will populate web/. Until then the stage is a no-op that just
# produces an empty web/dist directory so the backend image stays consistent.
FROM node:20-alpine AS frontend
WORKDIR /app
COPY web/ ./web/
RUN if [ -f web/package.json ]; then \
cd web && npm ci && npm run build; \
else \
mkdir -p web/dist; \
fi
# ----- stage 2: build backend -------------------------------------------------
FROM golang:1.22-alpine AS backend
WORKDIR /src
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
COPY --from=frontend /app/web/dist ./web/dist
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" \
-o /out/git-graph ./cmd/server
# ----- stage 3: runtime -------------------------------------------------------
FROM alpine:3.19
RUN apk add --no-cache git ca-certificates wget tini \
&& adduser -D -H -u 10001 app \
&& mkdir -p /data \
&& chown app:app /data
COPY --from=backend /out/git-graph /usr/local/bin/git-graph
VOLUME ["/data"]
EXPOSE 8080
USER app
HEALTHCHECK --interval=10s --timeout=3s --start-period=60s \
CMD wget -qO- http://localhost:8080/healthz || exit 1
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/git-graph"]