-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (22 loc) · 706 Bytes
/
Dockerfile
File metadata and controls
32 lines (22 loc) · 706 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
# ---- Build Stage ----
FROM golang:1.25-alpine AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the rest of the application code
COPY . .
# Build the Go application as a static binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -trimpath -o main ./cmd/app
# Create a lightweight image for the final binary
FROM gcr.io/distroless/static
WORKDIR /root/
# Copy the compiled binary from the builder stage
COPY --from=builder /app/main .
# Expose application port (change if needed)
ENV PORT=8080
EXPOSE ${PORT}
# Run the application
CMD ["./main"]