2025-10-20 08:54:21 +01:00
|
|
|
# Build stage
|
|
|
|
|
FROM golang:1.25-alpine AS builder
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy go mod files
|
|
|
|
|
COPY go.mod ./
|
|
|
|
|
|
|
|
|
|
# Download dependencies
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
|
|
# Copy source code
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# Build binary
|
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o cv-server -ldflags="-s -w" .
|
|
|
|
|
|
|
|
|
|
# Runtime stage
|
|
|
|
|
FROM alpine:latest
|
|
|
|
|
|
|
|
|
|
# Install CA certificates for HTTPS
|
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
|
|
|
|
|
|
WORKDIR /root/
|
|
|
|
|
|
|
|
|
|
# Copy binary from builder
|
|
|
|
|
COPY --from=builder /app/cv-server .
|
|
|
|
|
|
|
|
|
|
# Copy application files
|
|
|
|
|
COPY templates templates/
|
|
|
|
|
COPY data data/
|
|
|
|
|
COPY static static/
|
|
|
|
|
|
|
|
|
|
# Expose port
|
2025-10-29 14:04:24 +00:00
|
|
|
EXPOSE 1999
|
2025-10-20 08:54:21 +01:00
|
|
|
|
|
|
|
|
# Set production environment
|
|
|
|
|
ENV GO_ENV=production
|
2025-10-29 14:04:24 +00:00
|
|
|
ENV PORT=1999
|
2025-10-20 08:54:21 +01:00
|
|
|
|
|
|
|
|
# Health check
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
2025-10-29 14:04:24 +00:00
|
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:1999/health || exit 1
|
2025-10-20 08:54:21 +01:00
|
|
|
|
|
|
|
|
# Run the binary
|
|
|
|
|
CMD ["./cv-server"]
|