-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 779 Bytes
/
Dockerfile
File metadata and controls
39 lines (27 loc) · 779 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
# Build stage
FROM golang:1.21-alpine AS builder
# Set working directory
WORKDIR /app
# Install git (needed for go mod download)
RUN apk add --no-cache git
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the application with static linking
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o main .
# Runtime stage - using scratch for minimal image
FROM scratch
# Copy the statically linked binary
COPY --from=builder /app/main /main
# Copy content files (includes both .md and .css files)
COPY content/ /content/
# Expose port
EXPOSE 8080
# Set environment variables
ENV PORT=8080
ENV CONTENT_DIR=/content
# Run the application
ENTRYPOINT ["/main"]