github.com/timoth-y/kicksware-api/order-service@v0.0.0-20201002192818-87b546a7ae5a/docker/Dockerfile (about) 1 # Service dev image 2 FROM golang:alpine as dev 3 # Name service 4 LABEL Name=middleware-order-service 5 # Enable gomod & other env 6 ENV GO111MODULE=on \ 7 CGO_ENABLED=0 \ 8 GOOS=linux \ 9 GOARCH=amd64 10 # Setup working directory /build 11 WORKDIR /build 12 # Copy source code into the container 13 ADD . /build 14 # Copy & download dependency using go mod 15 COPY go.mod . 16 COPY go.sum . 17 RUN go mod download 18 # Build the service 19 RUN go build -o main . 20 # Move to /dist directory - place for resulting binaries 21 WORKDIR /dist 22 # Copy binary from build to main folder 23 RUN cp /build/main . 24 # Export necessary port 25 EXPOSE 8080 26 # Command to run service container when the container starts 27 CMD ["/dist/main"] 28 29 30 # Service prod image 31 FROM alpine:3.9.2 as prod 32 # Setup working directory /root/ 33 WORKDIR /root/ 34 # Copy service resulting binaries 35 COPY --from=dev /dist . 36 # Service listens on port 8080. 37 EXPOSE 8080 38 # Run product service container when the container starts 39 ENTRYPOINT ["./main"] 40 41 42