-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (44 loc) · 1.85 KB
/
Dockerfile
File metadata and controls
59 lines (44 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
56
57
58
59
# ── Build Arguments ────────────────────────────────────────────────────────
ARG GOLANG_VERSION=1.25
ARG ALPINE_VERSION=3.21
# ── Stage 1: Build ───────────────────────────────────────────────────────────
FROM golang:${GOLANG_VERSION}-alpine AS builder
# Build args from GitHub Actions
ARG VERSION=dev
ARG BUILDTIME
ARG GITCOMMIT
RUN apk add --no-cache git ca-certificates tzdata
WORKDIR /build
# Cache dependencies
COPY go.mod go.sum ./
RUN go mod download
# Build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w \
-X pindou/internal/version.Version=${VERSION} \
-X pindou/internal/version.BuildTime=${BUILDTIME} \
-X pindou/internal/version.GitCommit=${GITCOMMIT}" \
-o /out/pindou \
./cmd/server
# ── Stage 2: Minimal runtime ─────────────────────────────────────────────────
FROM alpine:${ALPINE_VERSION}
LABEL org.opencontainers.image.source="https://github.com/czyt/pindou"
LABEL org.opencontainers.image.description="Pindou - Bead Art Pattern Tool"
LABEL org.opencontainers.image.licenses="MIT"
RUN apk add --no-cache ca-certificates tzdata wget \
&& addgroup -S pindou \
&& adduser -S -G pindou pindou \
&& mkdir -p /app/data \
&& chown -R pindou:pindou /app
COPY --from=builder /out/pindou /app/pindou
WORKDIR /app
USER pindou
EXPOSE 8080
# Persistent volumes
VOLUME ["/app/data"]
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://localhost:8080/ || exit 1
ENTRYPOINT ["/app/pindou"]
CMD []