go mod tidy in Docker build causes disk space issues on CI runners (compiling modernc.org/ccgo pulls many C files). go.mod/go.sum are committed to repo, so go mod download + go build is sufficient.
34 lines
648 B
Docker
34 lines
648 B
Docker
# Build stage
|
|
FROM golang:1.27-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache git make
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# Copy source
|
|
COPY . .
|
|
|
|
# Build binary
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /ym-dl ./cmd/ym-dl
|
|
|
|
# Runtime stage
|
|
FROM gcr.io/distroless/static-debian12:nonroot
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy binary
|
|
COPY --from=builder /ym-dl /app/ym-dl
|
|
|
|
# Copy config example
|
|
COPY config.yaml.example /app/config.yaml.example
|
|
|
|
# Run as non-root user (distroless uses nonroot:nonroot by default)
|
|
USER nonroot:nonroot
|
|
|
|
ENTRYPOINT ["/app/ym-dl"]
|
|
CMD ["--config", "/config/config.yaml"] |