summaryrefslogtreecommitdiffstats
path: root/Dockerfile
diff options
context:
space:
mode:
authorRyan Skoblenick <ryan@skoblenick.com>2018-03-18 16:54:49 -0400
committerAnthony Fok <foka@debian.org>2018-06-14 15:47:04 -0600
commit8531ec7ca36fd35a57fba06bbb06a65c94dfd3ed (patch)
tree9a57c6b8e570377e66def24d8e113ea280154d28 /Dockerfile
parent9f27091e1067875e2577c331acc60adaef5bb234 (diff)
Update Dockerfile to a multi-stage build
- Hugo container is based on SCRATCH to further reduce the footprint and the vulnerability surface - Update Alpine image to 3.7 in the build container - Update Go Lang to 1.10 in the build container - Add .dockerignore file per the Docker best practices Closes #4154, #4155, #4157
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile34
1 files changed, 19 insertions, 15 deletions
diff --git a/Dockerfile b/Dockerfile
index 14834dcc2..1086f4f97 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,23 +1,27 @@
-FROM golang:1.9.0-alpine3.6 AS build
+# GitHub: https://github.com/gohugoio
+# Twitter: https://twitter.com/gohugoio
+# Website: https://gohugo.io/
-RUN apk add --no-cache --virtual git musl-dev
-RUN go get github.com/golang/dep/cmd/dep
+FROM golang:1.10.0-alpine3.7 AS build
+
+ENV CGO_ENABLED=0
+ENV GOOS=linux
WORKDIR /go/src/github.com/gohugoio/hugo
-ADD . /go/src/github.com/gohugoio/hugo/
-RUN dep ensure
-RUN go install -ldflags '-s -w'
+RUN apk add --no-cache \
+ git \
+ musl-dev && \
+ go get github.com/golang/dep/cmd/dep
+COPY . /go/src/github.com/gohugoio/hugo/
+RUN dep ensure -vendor-only && \
+ go install -ldflags '-s -w'
+
+# ---
-FROM alpine:3.6
-RUN \
- adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \
- apk add --no-cache \
- dumb-init
-COPY --from=build /go/bin/hugo /bin/hugo
-USER hugo
+FROM scratch
+COPY --from=build /go/bin/hugo /hugo
WORKDIR /site
VOLUME /site
EXPOSE 1313
-
-ENTRYPOINT ["/usr/bin/dumb-init", "--", "hugo"]
+ENTRYPOINT [ "/hugo" ]
CMD [ "--help" ]