CI / test (push) Failing after 35s
Add a cache-optimized multi-stage Dockerfile with non-root runtime, compose service definitions for local/dev execution, CI Go version alignment, and docs/path cleanup updates. Made-with: Cursor
32 lines
743 B
Docker
32 lines
743 B
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder
|
|
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
|
|
WORKDIR /src
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
git ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY go.mod ./
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
go mod download
|
|
|
|
COPY . .
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
|
|
go build -p "$(nproc)" -trimpath -ldflags="-s -w" -o /out/api ./cmd/api
|
|
|
|
FROM gcr.io/distroless/static-debian12:nonroot
|
|
|
|
WORKDIR /app
|
|
COPY --from=builder /out/api /app/api
|
|
|
|
ENV ADDR=:8080
|
|
EXPOSE 8080
|
|
|
|
ENTRYPOINT ["/app/api"]
|