From b8ff360407098a9026d10c298abd94fb3a310744 Mon Sep 17 00:00:00 2001 From: Miki Date: Tue, 4 Jun 2024 15:57:36 +0200 Subject: [PATCH] +Dockerfile --- Dockerfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9329486 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# syntax=docker/dockerfile:1 + +# Build the application from source +FROM golang:1.19 AS build-stage + +WORKDIR /app + +COPY go.mod go.sum ./ +RUN go mod download + +COPY *.go ./ + +RUN CGO_ENABLED=0 GOOS=linux go build -o /GPT-backend + +# Run the tests in the container +FROM build-stage AS run-test-stage +RUN go test -v ./... + +# Deploy the application binary into a lean image +FROM gcr.io/distroless/base-debian11 AS build-release-stage + +WORKDIR / + +COPY --from=build-stage /GPT-backend /GPT-backend + +EXPOSE 4000 + +USER nonroot:nonroot + +ENTRYPOINT ["/GPT-backend"] \ No newline at end of file