-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from buzzfeed/dockerfile-optimization
docker: switch to multistage build
- Loading branch information
Showing
2 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
FROM golang:1.9.2 | ||
# ============================================================================= | ||
# build stage | ||
# | ||
# install golang dependencies & build binaries | ||
# ============================================================================= | ||
FROM golang:1.10 AS build | ||
|
||
RUN apt-get update && apt-get install -y curl bash git jq gettext | ||
ENV GOFLAGS='-ldflags="-s -w"' | ||
ENV CGO_ENABLED=0 | ||
|
||
# install gpm dependencies | ||
COPY gpm /tmp/gpm | ||
COPY Godeps /tmp/Godeps | ||
RUN cd /tmp && ./gpm | ||
# use gpm to install dependencies | ||
COPY Godeps gpm /tmp/ | ||
RUN cd /tmp && ./gpm install | ||
|
||
COPY / /go/src/github.com/buzzfeed/sso/ | ||
WORKDIR /go/src/github.com/buzzfeed/sso | ||
|
||
RUN cd /go/src/github.com/buzzfeed/sso/cmd/sso-auth; go build -o /bin/sso-auth | ||
RUN cd /go/src/github.com/buzzfeed/sso/cmd/sso-proxy; go build -o /bin/sso-proxy | ||
COPY cmd ./cmd | ||
COPY internal ./internal | ||
RUN cd cmd/sso-auth && go build -o /bin/sso-auth | ||
RUN cd cmd/sso-proxy && go build -o /bin/sso-proxy | ||
|
||
|
||
# ============================================================================= | ||
# final stage | ||
# | ||
# add static assets and copy binaries from build stage | ||
# ============================================================================= | ||
FROM debian:stable-slim | ||
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* | ||
WORKDIR /sso | ||
COPY ./static ./static | ||
COPY --from=build /bin/sso-* /bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters