Skip to content

Commit

Permalink
Merge pull request #22 from buzzfeed/dockerfile-optimization
Browse files Browse the repository at this point in the history
docker: switch to multistage build
  • Loading branch information
Shraya Ramani committed Aug 23, 2018
2 parents ccf511c + 8f659e9 commit f140940
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
37 changes: 28 additions & 9 deletions Dockerfile
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/
1 change: 0 additions & 1 deletion Godeps
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
github.com/18F/hmacauth 1.0.1
gopkg.in/yaml.v2 v2
github.com/imdario/mergo v0.3.4
github.com/BurntSushi/toml d94612f9fc140360834f9742158c70b5c5b5535b
github.com/bitly/go-simplejson da1a8928f709389522c8023062a3739f3b4af419
github.com/mreiferson/go-options 77551d20752b54535462404ad9d877ebdb26e53d
github.com/datadog/datadog-go/statsd c74bd0589c83817c93e4eff39ccae69d6c46df9b
Expand Down

0 comments on commit f140940

Please sign in to comment.