From b2569647fb47b221ef25e8bb004d63a8e7fcd4d7 Mon Sep 17 00:00:00 2001 From: Julian Hamann Date: Sun, 18 Feb 2024 11:52:01 +0100 Subject: [PATCH] added dockerfile added and testet dockerfile --- dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 dockerfile diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..acdb113 --- /dev/null +++ b/dockerfile @@ -0,0 +1,38 @@ +# build stage +## import image +FROM golang:alpine AS build_base + +## add git +RUN apk add --no-cache git + +## cd into global 700 dir (image specific) +WORKDIR /go + +## populate the module cache based on the go.{mod,sum} files. +COPY go.mod . +COPY go.sum . +## download the modules +RUN go mod download + +## copy all files into build stage +COPY . . +## BUILD BUILD BUILD! +RUN go build -o ./out/gosh . + + +# run stage +## import image +FROM alpine:latest +## install certificates +RUN apk add ca-certificates + +## copy app from build stage to run stage +COPY --from=build_base /go/out/gosh /app/gosh + +## copy files from build stage to run stage +COPY --from=build_base /go/* /app + +## expose port +EXPOSE 8080 +## run app +CMD ["/app/gosh", "-config", "/app/gosh.yml"]