-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (39 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
56 lines (39 loc) · 1.19 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
# G0 CMS - Lightweight CMS
# Multi-stage build for minimal image size
# === BUILD STAGE ===
FROM golang:1.22-alpine AS builder
WORKDIR /build
# Install git for go mod download (some deps need it)
RUN apk add --no-cache git
# Copy go mod files first (better layer caching)
COPY go.mod go.sum ./
RUN go mod download
# Copy source
COPY . .
# Build static binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-w -s" \
-o g0 .
# === RUNTIME STAGE ===
FROM alpine:3.19
# Add ca-certificates for HTTPS (OAuth needs it)
RUN apk add --no-cache ca-certificates tzdata
# Create non-root user
RUN adduser -D -h /app appuser
WORKDIR /app
# Copy binary from builder
COPY --from=builder /build/g0 /app/g0
# Create data directory (config + database)
# Mount this as a volume to persist data
RUN mkdir -p /app/data && chown -R appuser:appuser /app
# Volume for persistent data (config.yaml + database)
VOLUME /app/data
# Switch to non-root user
USER appuser
# Expose port (default 8080, configurable via config.yaml)
EXPOSE 8080
# Healthcheck
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q --spider http://localhost:8080/ || exit 1
# Run
CMD ["/app/g0"]