Files
delivery-tracker/backend/Dockerfile
2026-04-14 15:39:21 +06:00

35 lines
562 B
Docker

# Stage 1: Builder
FROM golang:1.25-alpine AS builder
WORKDIR /app
# Install git and build 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 the application
RUN CGO_ENABLED=0 GOOS=linux go build -o api ./cmd/api
# Stage 2: Production
FROM alpine:latest AS production
RUN apk --no-cache add ca-certificates
WORKDIR /app
# Copy binary from builder
COPY --from=builder /app/api .
# Copy migrations
COPY internal/db/migrations ./migrations
EXPOSE 8080
CMD ["./api"]