-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (31 loc) · 893 Bytes
/
Dockerfile
File metadata and controls
44 lines (31 loc) · 893 Bytes
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
# Build stage
FROM golang:1.24-alpine AS builder
WORKDIR /app
# Install ca-certificates for HTTPS and git for go modules
RUN apk add --no-cache ca-certificates git
# Copy go mod files first for better caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags='-w -s -extldflags "-static"' \
-o /app/api \
./cmd/api
# Runtime stage
FROM alpine:3.20
# Install CA certificates for HTTPS and psql for migrations
RUN apk add --no-cache ca-certificates postgresql-client
# Copy the binary
COPY --from=builder /app/api /api
# Copy migrations
COPY --from=builder /app/migrations /migrations
# Copy static files (frontend)
COPY --from=builder /app/static /static
# Set working directory so relative paths work
WORKDIR /
# Expose port
EXPOSE 8080
# Run the binary
CMD ["/api"]