Files
boc/backend/Dockerfile
T

44 lines
777 B
Docker
Raw Normal View History

# BOC Backend Dockerfile
# Multi-stage build for minimal image
FROM golang:1.22-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
COPY . .
# Build
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o boc .
# Final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /app
# Copy binary
COPY --from=builder /app/boc .
COPY --from=builder /app/db/migrations ./db/migrations
# Create non-root user
RUN addgroup -g 1000 -S boc && \
adduser -u 1000 -S boc -G boc
USER boc
EXPOSE 9092
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost:9092/health || exit 1
CMD ["./boc"]