From 226f44742bce8ea36ef90ff59320b253ec2f37ea Mon Sep 17 00:00:00 2001 From: "J. Kitajima" Date: Thu, 16 Jan 2025 22:08:15 -0300 Subject: [PATCH] build: Added `Dockerfile` --- .dockerignore | 2 ++ Dockerfile | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e279a27 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.github/ +api/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d52e93e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# syntax=docker/dockerfile:1 +FROM golang:1.23-alpine3.21 AS build +WORKDIR /repo +ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN go build -ldflags="-s -w" -o ./bin/server ./cmd/server + +FROM gcr.io/distroless/static-debian12:nonroot +WORKDIR /bin +USER nonroot:nonroot +EXPOSE 80 443 +COPY --from=build /repo/env.local.yaml ./ +COPY --from=build /repo/bin/server ./ +ENTRYPOINT [ "/bin/server" ] \ No newline at end of file