From eb7439a7d0dffdba757cb77496647ff89a3b6de6 Mon Sep 17 00:00:00 2001 From: Callum Yuille Date: Thu, 11 Jun 2026 11:49:30 +0100 Subject: [PATCH] Add Dockerfile and document Docker usage Multi-stage build producing a static binary on a distroless base. Co-Authored-By: Claude Fable 5 --- Dockerfile | 10 ++++++++++ README.md | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..79a2acb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM golang:1.22-alpine AS build +WORKDIR /src +COPY go.mod ./ +COPY . . +RUN CGO_ENABLED=0 go build -o /out/urlshort ./cmd/server + +FROM gcr.io/distroless/static-debian12 +COPY --from=build /out/urlshort /urlshort +EXPOSE 8080 +ENTRYPOINT ["/urlshort"] diff --git a/README.md b/README.md index 6e98da6..821a26f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,13 @@ go run ./cmd/server The server listens on `:8080` by default; override with the `ADDR` environment variable. +### Docker + +```sh +docker build -t urlshort . +docker run --rm -p 8080:8080 urlshort +``` + ## API | Method | Path | Description |