this repo has no description
at main 1.3 kB view raw
1# Build stage 2FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder 3 4# Install build dependencies 5RUN apk add --no-cache git gcc musl-dev 6 7WORKDIR /build 8 9# Copy go mod files 10COPY go.mod go.sum ./ 11RUN --mount=type=cache,target=/go/pkg/mod go mod download 12 13# Copy source code 14COPY . . 15 16# Build arguments for cross-compilation 17ARG TARGETOS 18ARG TARGETARCH 19 20# Build the binary 21RUN --mount=type=cache,target=/go/pkg/mod \ 22 --mount=type=cache,target=/root/.cache/go-build \ 23 CGO_ENABLED=1 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ 24 go build -ldflags="-w -s" -o brooke-spin ./cmd/brooke-spin 25 26# Runtime stage 27FROM alpine:latest 28 29# Install runtime dependencies 30RUN apk add --no-cache ca-certificates tzdata 31 32# Create non-root user 33RUN addgroup -g 1000 brooke && \ 34 adduser -D -u 1000 -G brooke brooke 35 36WORKDIR /app 37 38# Copy binary and entrypoint from builder 39COPY --from=builder /build/brooke-spin /app/brooke-spin 40COPY entrypoint.sh /app/entrypoint.sh 41 42# Set ownership and make entrypoint executable 43RUN chown -R brooke:brooke /app && \ 44 chmod +x /app/entrypoint.sh 45 46# Switch to non-root user 47USER brooke 48 49# Use entrypoint to ensure data directory exists 50ENTRYPOINT ["/app/entrypoint.sh"] 51 52# Default command 53CMD ["/app/brooke-spin", "-config", "/app/config.yaml"]