Files
aggios.app/backend/Dockerfile
2025-12-17 13:36:23 -03:00

32 lines
596 B
Docker

# Build stage
FROM golang:1.23-alpine AS builder
WORKDIR /build
# Copy go module files
COPY go.mod ./
RUN test -f go.sum && cp go.sum go.sum.bak || true
# Copy entire source tree (internal/, cmd/)
COPY . .
# Ensure go.sum is up to date
RUN go mod tidy
# Build from root (module is defined there)
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server ./cmd/server
# Runtime image
FROM alpine:latest
RUN apk --no-cache add ca-certificates tzdata postgresql-client
WORKDIR /root/
# Copy binary from builder
COPY --from=builder /build/server .
EXPOSE 8080
CMD ["./server"]