# Build stage FROM golang:1.26.2-alpine AS builder WORKDIR /app # Install build dependencies RUN apk add --no-cache git # Copy go mod files COPY go.mod go.sum ./ RUN go mod download # Copy source code COPY . . # Build the application RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o /app/auth-service ./cmd/api # Final stage FROM alpine:3.22 WORKDIR /app # Install ca-certificates for HTTPS RUN apk add --no-cache ca-certificates # Copy binary from builder COPY --from=builder /app/auth-service /app/ # Copy migrations COPY --from=builder /app/migrations /app/migrations EXPOSE 8080 CMD ["/app/auth-service"]