blob: 2010b09fa2f3ab1ffeb0379e3fba685f679ceaba (
plain) (
blame)
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
|
# Build stage
FROM golang:1.24-alpine AS builder
WORKDIR /app
# Install build dependencies
RUN apk add --no-cache git
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w -X main.version=$(git describe --tags --always --dirty 2>/dev/null || echo dev)" \
-o kaze ./cmd/kaze
# Runtime stage
FROM alpine:3.19
WORKDIR /app
# Install CA certificates for HTTPS requests
RUN apk add --no-cache ca-certificates tzdata
# Create non-root user
RUN adduser -D -u 1000 kaze
# Create data directory before switching user
RUN mkdir -p /app/data && chown -R kaze:kaze /app
# Copy binary from builder
COPY --from=builder --chown=kaze:kaze /app/kaze .
# Switch to non-root user
USER kaze
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1
# Run the application
# Config and database will be in /app/data volume mount
ENTRYPOINT ["./kaze"]
CMD ["--config", "/app/data/config.yaml"]
|