A community based topic aggregation platform built on atproto
at main 1.5 kB view raw
1# Coves AppView - Multi-stage Dockerfile 2# Builds a minimal production image for the Go server 3 4# Stage 1: Build 5FROM golang:1.24-alpine AS builder 6 7# Install build dependencies 8RUN apk add --no-cache git ca-certificates tzdata 9 10# Set working directory 11WORKDIR /build 12 13# Copy go mod files first (better caching) 14COPY go.mod go.sum ./ 15RUN go mod download 16 17# Copy source code 18COPY . . 19 20# Build the binary 21# CGO_ENABLED=0 for static binary (no libc dependency) 22# -ldflags="-s -w" strips debug info for smaller binary 23RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ 24 -ldflags="-s -w" \ 25 -o /build/coves-server \ 26 ./cmd/server 27 28# Stage 2: Runtime 29FROM alpine:3.19 30 31# Install runtime dependencies 32RUN apk add --no-cache ca-certificates tzdata 33 34# Create non-root user for security 35RUN addgroup -g 1000 coves && \ 36 adduser -u 1000 -G coves -s /bin/sh -D coves 37 38# Set working directory 39WORKDIR /app 40 41# Copy binary from builder 42COPY --from=builder /build/coves-server /app/coves-server 43 44# Copy migrations (needed for goose) 45# Must maintain path structure as app looks for internal/db/migrations 46COPY --from=builder /build/internal/db/migrations /app/internal/db/migrations 47 48# Set ownership 49RUN chown -R coves:coves /app 50 51# Switch to non-root user 52USER coves 53 54# Expose port 55EXPOSE 8080 56 57# Health check 58HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ 59 CMD wget --spider -q http://localhost:8080/xrpc/_health || exit 1 60 61# Run the server 62ENTRYPOINT ["/app/coves-server"]