-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
92 lines (66 loc) · 2.03 KB
/
Copy pathDockerfile
File metadata and controls
92 lines (66 loc) · 2.03 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Frontend build stage
FROM oven/bun AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package.json frontend/bun.lock ./
# Install frontend dependencies
RUN bun install --frozen-lockfile
# Copy frontend source
COPY frontend/ ./
# Build frontend
RUN bun run build
# Backend build stage
FROM golang:1.24-alpine AS backend-builder
# Install build dependencies
RUN apk add --no-cache git ca-certificates tzdata
WORKDIR /app
# Copy go mod files first for better caching
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags='-w -s -extldflags "-static"' \
-o main .
# Production stage
FROM alpine:latest
# Install runtime dependencies including GDAL for shapefile conversion
RUN apk add --no-cache \
ca-certificates \
tzdata \
wget \
curl \
gdal \
gdal-tools
# Create non-root user
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup
WORKDIR /app
# Create directories first
# Note: Data files are no longer shipped with the container
# Use the Data Manager UI at /data-manager to upload county data after deployment
RUN mkdir -p /app/oh /app/cache /app/scripts /app/uploads
# Copy binary from backend builder
COPY --from=backend-builder /app/main ./main
# Copy frontend build
COPY --from=frontend-builder /app/static-new ./static-new
# Copy other runtime files
COPY --from=backend-builder /app/docs ./docs
COPY --from=backend-builder /app/api-docs.yaml ./api-docs.yaml
COPY --from=backend-builder /app/migrations ./migrations
# Set permissions
RUN chown -R appuser:appgroup /app
# Set environment variables for production
ENV ENV=production
ENV GO_ENV=production
# Switch to non-root user
USER appuser
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
# Run the application
CMD ["./main"]