diff --git a/Dockerfile b/Dockerfile index 55bbc17..c8e41e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage Build -FROM golang:1.20 as build +FROM golang:1.23 as build ENV GOOS=linux ENV GOARCH=amd64 @@ -8,14 +8,14 @@ ENV CGO_ENABLED=0 WORKDIR /app COPY . ./ - RUN go mod download -RUN go build -o web + +RUN make build-web # Stage Run -FROM alpine:latest -WORKDIR /app -COPY --from=build /app/web . -RUN chmod +x web -CMD ["./web"] -EXPOSE 8080 \ No newline at end of file +FROM gcr.io/distroless/base-debian11 +WORKDIR / +COPY --from=build /app/bin/web /web +EXPOSE 8080 +USER nonroot:nonroot +ENTRYPOINT ["/web"] diff --git a/Makefile b/Makefile index 145a651..ae32f3c 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ build-cli: go build ./... go build -o bin/cli cmd/cli/main.go -docker: +docker-build: docker build -t gunni1/lib-api:local . docker-run: diff --git a/apprunner.yaml b/apprunner.yaml new file mode 100644 index 0000000..c69a5de --- /dev/null +++ b/apprunner.yaml @@ -0,0 +1,10 @@ +version: 1.0 +runtime: go1 +build: + commands: + build: + - go build -o bin/web main.go +run: + command: ./bin/web + network: + port: 8080 \ No newline at end of file