FROM golang:1.21-bullseye AS builder # Set working directory WORKDIR /app # Copy go.mod and go.sum files COPY go.mod go.sum ./ # Download dependencies RUN go mod download # Copy the source code COPY . . # Build the application RUN CGO_ENABLED=0 GOOS=linux go build -o bebank-server main.go # Use a smaller base image for the final image FROM alpine:3.18 # Add CA certificates for HTTPS support RUN apk --no-cache add ca-certificates WORKDIR /app # Copy the binary from the builder stage COPY --from=builder /app/bebank-server . # Copy any static files or configurations COPY --from=builder /app/.env . COPY --from=builder /app/public ./public # Expose port EXPOSE 7860 # Set environment variables ENV PORT=7860 ENV HOST=0.0.0.0 ENV GIN_MODE=release # Run the binary CMD ["./bebank-server"]