# Build stage FROM golang:1.24-alpine AS builder WORKDIR /app # Install git and other dependencies RUN apk add --no-cache git # Copy go mod files COPY go.mod go.sum ./ # Download dependencies RUN go mod download # Install goose RUN go install github.com/pressly/goose/v3/cmd/goose@latest # Copy source code COPY . . # Build the application RUN CGO_ENABLED=0 GOOS=linux go build -o main ./cmd/server/main.go # Production stage FROM alpine:latest # Install ca-certificates for HTTPS and postgresql client RUN apk --no-cache add ca-certificates tzdata postgresql-client WORKDIR /app # Copy binary from builder stage COPY --from=builder /app/main . # Copy goose for migrations COPY --from=builder /go/bin/goose /usr/local/bin/goose # Copy migrations COPY migrations ./migrations # Copy environment file if exists COPY .env.example .env # Expose port EXPOSE 8080 # Run the application CMD ["./main"]