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 |