Skip to content

Commit

Permalink
Use multi-stage builds
Browse files Browse the repository at this point in the history
  • Loading branch information
FX-HAO authored and codeskyblue committed Dec 27, 2017
1 parent 876b8cf commit bd7666b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
FROM golang:latest
RUN mkdir /app
WORKDIR /app
ENV SRC_DIR=/go/src/github.com/codeskyblue/gohttpserver
ADD . $SRC_DIR
RUN cd $SRC_DIR; go build; cp gohttpserver /app/
ENTRYPOINT ["/app/gohttpserver"]
FROM golang:1.9 AS build
WORKDIR /go/src/github.com/codeskyblue/gohttpserver
ADD . /go/src/github.com/codeskyblue/gohttpserver/
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gohttpserver .

FROM alpine:3.6
WORKDIR /app
RUN mkdir -p /app/public
VOLUME /app/public
ADD res ./res
COPY --from=build /go/src/github.com/codeskyblue/gohttpserver/gohttpserver .
EXPOSE 8000
CMD ["/app/gohttpserver", "--root=/app/public"]

0 comments on commit bd7666b

Please sign in to comment.