From 76e065dd0f1ebe5d50b71b8b358943b968c0a1b0 Mon Sep 17 00:00:00 2001 From: Maik Ellerbrock Date: Sun, 10 Dec 2017 02:01:52 +0100 Subject: [PATCH 1/2] fix(dockerfile): fix broken docker build and optimize dockerfile --- Dockerfile | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 889584b616b..52b17001a0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,35 @@ -FROM golang:1.9.0-alpine3.6 AS build +# GitHub: https://github.com/gohugoio/ +# Docker: https://hub.docker.com/r/gohugoio/ +# Twitter: https://twitter.com/gohugoio -RUN apk add --no-cache --virtual git musl-dev -RUN go get github.com/golang/dep/cmd/dep +FROM golang:1.10-rc-alpine3.7 AS build -WORKDIR /go/src/github.com/gohugoio/hugo -RUN dep ensure -ADD . /go/src/github.com/gohugoio/hugo/ -RUN 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 + git \ + musl-dev && \ + go get github.com/golang/dep/cmd/dep && \ + go get github.com/kardianos/govendor && \ + govendor get github.com/gohugoio/hugo && \ + cd /go/src/github.com/gohugoio/hugo && \ + dep ensure && \ + go install -ldflags '-s -w' + +# --- + +FROM alpine:3.7 + COPY --from=build /go/bin/hugo /bin/hugo + +RUN \ + adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \ + apk add --no-cache dumb-init + USER hugo WORKDIR /site VOLUME /site EXPOSE 1313 -ENTRYPOINT ["/usr/bin/dumb-init", "--", "hugo"] +ENTRYPOINT [ "/usr/bin/dumb-init", "--", "hugo" ] CMD [ "--help" ] + From 4930b0f96cb1958e67d1c7a0284691b75035666d Mon Sep 17 00:00:00 2001 From: Maik Ellerbrock Date: Sun, 10 Dec 2017 02:30:16 +0100 Subject: [PATCH 2/2] feat(docker): hugo from scratch + dockhub & quay account --- Dockerfile | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 52b17001a0b..87683eb60ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,14 @@ -# GitHub: https://github.com/gohugoio/ -# Docker: https://hub.docker.com/r/gohugoio/ -# Twitter: https://twitter.com/gohugoio +# GitHub: https://github.com/gohugoio/ +# DockerHub: https://hub.docker.com/r/gohugoio/ +# Quay: https://quay.io/user/gohugoio +# Twitter: https://twitter.com/gohugoio +# Website: https://gohugo.io/ FROM golang:1.10-rc-alpine3.7 AS build +ENV CGO_ENABLED=0 +ENV GOOS=linux + RUN \ apk add --no-cache \ git \ @@ -17,19 +22,12 @@ RUN \ # --- -FROM alpine:3.7 - -COPY --from=build /go/bin/hugo /bin/hugo +FROM scratch -RUN \ - adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \ - apk add --no-cache dumb-init +COPY --from=build /go/bin/hugo /hugo -USER hugo -WORKDIR /site -VOLUME /site EXPOSE 1313 -ENTRYPOINT [ "/usr/bin/dumb-init", "--", "hugo" ] +ENTRYPOINT [ "/hugo" ] CMD [ "--help" ]