2026-07-28 23:08:32 +00:00
|
|
|
# BOC Backend Dockerfile
|
|
|
|
|
# Multi-stage build for minimal image
|
|
|
|
|
|
|
|
|
|
FROM golang:1.22-alpine AS builder
|
2026-07-12 13:21:10 +00:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
|
RUN apk add --no-cache git
|
|
|
|
|
|
|
|
|
|
# Copy go mod files
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
2026-07-28 23:08:32 +00:00
|
|
|
# Copy source
|
2026-07-12 13:21:10 +00:00
|
|
|
COPY . .
|
|
|
|
|
|
2026-07-28 23:08:32 +00:00
|
|
|
# Build
|
2026-07-12 13:21:10 +00:00
|
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o boc .
|
|
|
|
|
|
|
|
|
|
# Final stage
|
|
|
|
|
FROM alpine:latest
|
|
|
|
|
|
2026-07-28 23:08:32 +00:00
|
|
|
RUN apk --no-cache add ca-certificates
|
2026-07-12 13:21:10 +00:00
|
|
|
|
2026-07-28 23:08:32 +00:00
|
|
|
WORKDIR /app
|
2026-07-12 13:21:10 +00:00
|
|
|
|
2026-07-28 23:08:32 +00:00
|
|
|
# Copy binary
|
2026-07-12 13:21:10 +00:00
|
|
|
COPY --from=builder /app/boc .
|
|
|
|
|
COPY --from=builder /app/db/migrations ./db/migrations
|
|
|
|
|
|
2026-07-28 23:08:32 +00:00
|
|
|
# Create non-root user
|
|
|
|
|
RUN addgroup -g 1000 -S boc && \
|
|
|
|
|
adduser -u 1000 -S boc -G boc
|
|
|
|
|
|
|
|
|
|
USER boc
|
|
|
|
|
|
2026-07-12 13:21:10 +00:00
|
|
|
EXPOSE 9092
|
|
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
2026-07-28 23:08:32 +00:00
|
|
|
CMD wget -qO- http://localhost:9092/health || exit 1
|
2026-07-12 13:21:10 +00:00
|
|
|
|
|
|
|
|
CMD ["./boc"]
|