Prevent 1GB source code from staying in the image

This commit is contained in:
Paul Cager
2020-12-18 00:12:39 +00:00
parent acdf692e81
commit 9122ef210f
+13 -6
View File
@@ -1,11 +1,18 @@
FROM paulcager/go-base:latest
FROM paulcager/go-base:latest as build
WORKDIR /go
COPY go.mod *.go ./src/osgrid-server/
RUN cd /go/src/osgrid-server && \
go install -v ./... && \
sha256sum /go/bin/osgrid-server
FROM debian:stable-slim
RUN apt-get update && apt-get -y upgrade
WORKDIR /app
COPY --from=build /go/bin/osgrid-server .
EXPOSE 9090
WORKDIR /go/src/osgrid-server
COPY go.mod *.go ./
RUN go install -v ./... && sha256sum /go/bin/osgrid-server && cd /go && rm -rf /go/src /go/pkg
CMD [ "/go/bin/osgrid-server" ]
CMD [ "/app/osgrid-server" ]