# Multi-stage build for smaller final image FROM golang:1.25-alpine AS builder # Install build dependencies for CGO (required for SQLite) RUN apk add --no-cache gcc musl-dev sqlite-dev # Set working directory WORKDIR /build # Copy go mod files COPY go.mod go.sum ./ # Download dependencies RUN go mod download # Copy source code COPY . . # Build the application with CGO enabled for SQLite RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o alpenqueue ./cmd/alpenqueue # Final stage - minimal image FROM alpine:latest # Install runtime dependencies RUN apk --no-cache add ca-certificates sqlite-libs # Create non-root user RUN addgroup -g 1001 -S alpenqueue && \ adduser -u 1001 -S alpenqueue -G alpenqueue # Set working directory WORKDIR /app # Copy binary from builder COPY --from=builder /build/alpenqueue . # Create directory for SQLite database RUN mkdir -p /app/data && chown -R alpenqueue:alpenqueue /app # Switch to non-root user USER alpenqueue # Expose port EXPOSE 8080 # Volume for persistent data VOLUME ["/app/data"] # Run the application CMD ["./alpenqueue"]