Update DOCKERFILE

This commit is contained in:
Fred Boniface 2023-09-06 01:38:46 +01:00
parent e40bfb4cd4
commit 7171bffc5e
2 changed files with 34 additions and 6 deletions

27
.dockerignore Normal file
View File

@ -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

View File

@ -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" ]
COPY --from=build /build/templates /bin/templates
COPY --from=build /build/static /bin/static
COPY --from=build /build/barcodes /bin/barcodes
CMD [ "/bin/barcodes" ]