Dockerfile.go
attributes
| source_path | assets/Dockerfile.go |
|---|---|
| source_sha256 | 04a56fd7b3617dbf83cc177532f216e999112c59e5e2f66f7fdde9c219eccdd7 |
| source_url | https://github.com/docker/skills/blob/ce4693b88722334625780ca8e9d54201b2d96f6d/skills/docker-build-strategies/assets/Dockerfile.go |
| supporting_skill_id | 40167 |
| upstream_revision | ce4693b88722334625780ca8e9d54201b2d96f6d |
# syntax=docker/dockerfile:1
# --- Build stage ---
FROM golang:1.23-alpine AS build
WORKDIR /src
# Cache dependency downloads; bind-mount the manifest since go mod download doesn't rewrite it
RUN --mount=type=bind,source=go.mod,target=go.mod \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=cache,target=/go/pkg/mod \
go mod download
# Build the binary
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/server ./cmd/server
# --- Runtime stage ---
FROM gcr.io/distroless/static-debian12:nonroot AS runtime
WORKDIR /app
COPY --from=build --link /app/server .
USER nonroot:nonroot
EXPOSE 8080
LABEL org.opencontainers.image.source="<source-repository-url>"
ENTRYPOINT ["./server"]
Children
No children yet.
Like how this is organised?
Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.