FROM golang:1.21-alpine AS builder WORKDIR /app # Copy go mod files COPY go.mod go.sum ./ RUN go mod download # Copy source code COPY . . # Build API server WORKDIR /app/api/rest RUN CGO_ENABLED=0 GOOS=linux go build -o api . FROM alpine:latest RUN apk --no-cache add ca-certificates WORKDIR /root/ COPY --from=builder /app/api/rest/api . CMD ["./api"]