From 5a5d8b7909153aa4b39f4f77bc90ff888101f473 Mon Sep 17 00:00:00 2001 From: tamsin woo Date: Sat, 24 Feb 2024 21:28:41 -0800 Subject: [PATCH] bump go to 1.22.0; add container setup use a multistage build so we don't leave the source code on the final artifact. --- Dockerfile | 16 ++++++++++++++++ go.mod | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..69ecc3f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.22.0-alpine3.19 as build + +WORKDIR /usr/src/app + +COPY go.mod go.sum ./ +RUN go mod download && go mod verify + +COPY . . +RUN go build -v -o /tmp/app ./cmd/web + + +FROM golang:1.22.0-alpine3.19 +ENV LOGFMT=json LOGLEVEL=DEBUG +COPY --from=build /tmp/app / +EXPOSE 4000 +CMD ["sh", "-c", "/app -logfmt=$LOGFMT -loglevel=$LOGLEVEL"] \ No newline at end of file diff --git a/go.mod b/go.mod index e2be010..22c82da 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module replication-systems.estradiol.cloud -go 1.21.4 +go 1.22.0 require ( github.com/julienschmidt/httprouter v1.3.0