# Stage 1: Build the application FROM golang:1.25.3-alpine AS base FROM base AS builder COPY . /app WORKDIR /app # Copy go.mod and go.sum first to leverage Docker's caching ENV GOPROXY=direct RUN apk add git RUN go mod download # Build the Go application # CGO_ENABLED=0 disables Cgo for a fully static binary # -a links all packages statically # -installsuffix cgo_non_shared avoids issues with shared libraries RUN CGO_ENABLED=0 GOOS=linux go build RUN ls -al # Stage 2: Create the final lean image FROM base WORKDIR /root/ # Copy the built binary from the builder stage COPY --from=builder /app/ordr-api . COPY --from=builder /app/.env . # Expose the port your Gin application listens on (e.g., 8080) EXPOSE 8080 # Command to run the application ENV GIN_MODE=release CMD ["./ordr-api"]