From 106d8c363174620bb0ac3dce620097f9e46cd808 Mon Sep 17 00:00:00 2001 From: Martin Strobel Date: Mon, 13 Aug 2018 15:59:41 -0700 Subject: [PATCH] Cleanup Dockerfiles (#437) * Cleanup Dockerfiles * Responding to review feedback * Preventing host copy of local and directories from being copied into builder containers. --- .dockerignore | 2 ++ Makefile | 6 ++++-- cmd/olympus/Dockerfile | 14 ++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..e15709fd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +**/node_modules/ +**/bin/ \ No newline at end of file diff --git a/Makefile b/Makefile index ff541cfb..40cb35cc 100644 --- a/Makefile +++ b/Makefile @@ -35,14 +35,16 @@ test-unit: test-e2e: ./scripts/test_e2e.sh +.PHONY: docker +docker: olympus-docker proxy-docker + .PHONY: olympus-docker olympus-docker: docker build -t gomods/olympus -f cmd/olympus/Dockerfile . .PHONY: proxy-docker proxy-docker: - # TODO: this needs to change to gomods/proxy - docker build -t gomods/athens -f cmd/proxy/Dockerfile . + docker build -t gomods/proxy -f cmd/proxy/Dockerfile . bench: ./scripts/benchmark.sh diff --git a/cmd/olympus/Dockerfile b/cmd/olympus/Dockerfile index ef5d6e82..dcb57ad8 100644 --- a/cmd/olympus/Dockerfile +++ b/cmd/olympus/Dockerfile @@ -5,12 +5,18 @@ # the olympus docker image FROM gobuffalo/buffalo:v0.11.0 as builder -RUN mkdir -p $GOPATH/src/github.com/gomods/athens -WORKDIR $GOPATH/src/github.com/gomods/athens -ADD . . +RUN mkdir -p $GOPATH/src/github.com/gomods/athens/cmd/olympus WORKDIR $GOPATH/src/github.com/gomods/athens/cmd/olympus -RUN buffalo build -s -o /bin/app +# this will cache the npm install step, unless package.json changes +ADD cmd/olympus/package.json . +ADD cmd/olympus/yarn.lock . +RUN yarn install --no-progress + +WORKDIR $GOPATH/src/github.com/gomods/athens +ADD . . + +RUN cd cmd/olympus && buffalo build -s -o /bin/app FROM alpine RUN apk add --no-cache bash