aboutsummaryrefslogtreecommitdiff
path: root/Dockerfile
blob: 50f700352aa56f7fd4ecf5d13e225ba70e16fb4e (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
52
53
54
# 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 with version info
RUN CGO_ENABLED=0 GOOS=linux go build \
    -ldflags="-s -w \
    -X main.version=$(git describe --tags --always --dirty 2>/dev/null || echo dev) \
    -X main.commit=$(git rev-parse --short HEAD 2>/dev/null || echo none) \
    -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
    -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"]