Files
econ/backend/Dockerfile
2026-03-31 01:28:28 -03:00

34 lines
512 B
Docker

FROM golang:1.23-alpine AS builder
WORKDIR /app
# Install 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 binary
RUN CGO_ENABLED=0 GOOS=linux go build -o /server ./cmd/server
# Final stage
FROM alpine:3.19
WORKDIR /app
# Install ca-certificates for HTTPS
RUN apk add --no-cache ca-certificates
# Copy binary from builder
COPY --from=builder /server .
# Expose port
EXPOSE 8080
# Run the binary
CMD ["./server"]