-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (35 loc) · 1.38 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (35 loc) · 1.38 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
# =============================================================================
# Stage 1: Build
# =============================================================================
FROM golang:1.24-alpine AS builder
RUN apk add --no-cache nodejs npm
WORKDIR /src
# Cache Go module dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy all source files
# Note: frontend/node_modules/, frontend-dist/ are excluded via .dockerignore
COPY . .
# Build frontend
WORKDIR /src/frontend
RUN npm ci && npm run build
# Build Go binary (CGO disabled for pure-Go SQLite compatibility on alpine)
WORKDIR /src
RUN CGO_ENABLED=0 go build -o /app/lingma2api .
# =============================================================================
# Stage 2: Runtime (minimal alpine)
# =============================================================================
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata wget
# Create non-root user
RUN adduser -D -u 1000 appuser
WORKDIR /app
COPY --from=builder /app/lingma2api /app/lingma2api
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
USER appuser
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:8080/ || exit 1
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["/app/lingma2api", "-config", "/app/config/config.yaml"]