Skip to content

Commit

Permalink
✨ multi stage build
Browse files Browse the repository at this point in the history
  • Loading branch information
nobiki committed Nov 12, 2018
1 parent 0d43c9a commit 1e0df63
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
19 changes: 13 additions & 6 deletions services/docker-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
FROM golang:1.11.1-stretch

RUN go get -u github.com/golang/dep/cmd/dep

FROM golang:1.11.1-stretch as develop
WORKDIR /apps

RUN go get -u github.com/golang/dep/cmd/dep
ENV GOROOT /usr/local/go/
ENV GOPATH /apps/go

ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin


FROM golang:1.11.1-stretch as build
WORKDIR /apps
COPY ./apps /apps
ADD . /apps
RUN go build -o hello hello.go


FROM busybox as release
WORKDIR /apps
COPY --from=build /apps/hello /usr/local/bin/hello
ENTRYPOINT ["/usr/local/bin/hello"]
6 changes: 4 additions & 2 deletions services/docker-base/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: '2'
version: '2.3'

services:

base-container:
container_name: base-container
hostname: base-container
image: base-container
build: ${PWD}/.
build:
context: ${PWD}/.
target: release
networks:
base-net:
ipv4_address: 172.56.0.2
Expand Down
2 changes: 1 addition & 1 deletion services/docker-network.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '2'
version: '2.3'

networks:
base-net:
Expand Down

0 comments on commit 1e0df63

Please sign in to comment.