-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
36 lines (26 loc) · 861 Bytes
/
Containerfile
File metadata and controls
36 lines (26 loc) · 861 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
#############################
# Stage 1: Build Go Binary
#############################
FROM docker.io/library/golang:1.24-alpine AS builder
WORKDIR /app
# Install GCC and musl-dev for CGO support (required by go-sqlite3)
RUN apk add --no-cache gcc musl-dev
# Copy Go module files and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the Go binary with CGO enabled and fully static linking
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -ldflags "-s -w -extldflags \"-static\"" -o nimble .
#############################
# Stage 2: Final Image
#############################
FROM scratch
# Copy the compiled binary
COPY --from=builder /app/nimble /nimble
# Copy the schema for DB initialization
COPY --from=builder /app/sqlc /sqlc
# Expose the port
EXPOSE 8080
# Run
ENTRYPOINT ["/nimble"]