1FROM golang:1.25-alpine AS builder
2
3WORKDIR /app
4
5# Copy go mod files
6COPY go.mod go.sum ./
7RUN go mod download
8
9# Copy source code
10COPY . .
11
12# Build the binary
13RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o api ./cmd/api
14
15FROM alpine:latest
16
17RUN apk --no-cache add ca-certificates
18
19WORKDIR /root/
20
21# Copy binary from builder
22COPY --from=builder /app/api .
23
24# Expose port
25EXPOSE 8080
26
27# Run the binary
28CMD ["./api"]