From 5039853edcb49b53859167648c26b80f7577abba Mon Sep 17 00:00:00 2001 From: Brad Koehn Date: Wed, 21 Nov 2018 10:38:56 -0600 Subject: [PATCH 1/4] Updated Dockerfile to produce smaller image with minimum content and a few extra features; added .dockerignore --- .dockerignore | 1 + Dockerfile | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9414382 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +Dockerfile diff --git a/Dockerfile b/Dockerfile index a2dd072..535b45d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.11.2-alpine3.8 +FROM golang:1.11.2-alpine3.8 as build RUN apk add --update nodejs nodejs-npm make git RUN npm install -g less @@ -11,5 +11,21 @@ RUN make install RUN make ui RUN make deps +RUN mkdir /stage && \ + cp -R /go/bin \ + /go/src/app/templates \ + /go/src/app/static \ + /go/src/app/schema.sql \ + /go/src/app/pages \ + /go/src/app/keys \ + /stage && ls -l /stage + +FROM golang:1.11.2-alpine3.8 + +COPY --from=build --chown=daemon:daemon /stage /go + +VOLUME /go/keys EXPOSE 8080 +USER daemon + CMD ["writefreely"] From f2a07db23ad56c90092da400ee04b5ef3de46609 Mon Sep 17 00:00:00 2001 From: Brad Koehn Date: Wed, 21 Nov 2018 12:51:37 -0600 Subject: [PATCH 2/4] switched to much smaller alpine image since golang not required at runtime --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 535b45d..ddcfdf5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,12 +20,13 @@ RUN mkdir /stage && \ /go/src/app/keys \ /stage && ls -l /stage -FROM golang:1.11.2-alpine3.8 +FROM alpine:3.8 COPY --from=build --chown=daemon:daemon /stage /go +WORKDIR /go VOLUME /go/keys EXPOSE 8080 USER daemon -CMD ["writefreely"] +CMD ["bin/writefreely"] From aebad1ce54ffaf7106903d7723e0f6219b2b2803 Mon Sep 17 00:00:00 2001 From: Brad Koehn Date: Thu, 22 Nov 2018 06:56:29 -0600 Subject: [PATCH 3/4] added .git to make builds cache more effectively and run faster --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 9414382..96f81bc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ Dockerfile +.git From 6f0c7aed66f6d136e3ca35ed2e02b0b8ff185d70 Mon Sep 17 00:00:00 2001 From: Brad Koehn Date: Thu, 22 Nov 2018 06:57:05 -0600 Subject: [PATCH 4/4] removed an unnecessary debugging statement --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ddcfdf5..bbbedd0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN mkdir /stage && \ /go/src/app/schema.sql \ /go/src/app/pages \ /go/src/app/keys \ - /stage && ls -l /stage + /stage FROM alpine:3.8