From 7171bffc5ea0d8181dea19ddad68af9b6faa2dc0 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Wed, 6 Sep 2023 01:38:46 +0100 Subject: [PATCH] Update DOCKERFILE --- .dockerignore | 27 +++++++++++++++++++++++++++ Dockerfile | 13 +++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b0f09de --- /dev/null +++ b/.dockerignore @@ -0,0 +1,27 @@ +# Compiled binaries +barcodes + +Dockerfile +.dockerignore + +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d0dd50c..8be64cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,14 @@ +# Build stage FROM golang:latest as build WORKDIR /build COPY . . RUN go test ./... -RUN go build +RUN CGO_ENABLED=0 go build . +# Final stage FROM scratch EXPOSE 8500 -WORKDIR /app -COPY --from=build /build/templates /app/templates -COPY --from=build /build/static /app/static -COPY --from=build /build/barcodes /app/barcodes -CMD [ "/app/barcodes" ] \ No newline at end of file +COPY --from=build /build/templates /bin/templates +COPY --from=build /build/static /bin/static +COPY --from=build /build/barcodes /bin/barcodes +CMD [ "/bin/barcodes" ]