Files
GPT_Management/backend/Dockerfile
2026-01-14 15:37:35 +08:00

38 lines
642 B
Docker

# Build stage
FROM golang:1.25-alpine AS builder
WORKDIR /app
# Install build dependencies
RUN apk add --no-cache git
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies
RUN go mod download
# Copy the source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main ./cmd/main.go
# Final stage
FROM alpine:latest
WORKDIR /app
# Install ca-certificates for HTTPS
RUN apk --no-cache add ca-certificates tzdata
# Copy binary from builder
COPY --from=builder /app/main .
COPY --from=builder /app/.env.example .
# Expose port
EXPOSE 8080
# Command to run
CMD ["./main"]