summaryrefslogtreecommitdiffstats
path: root/Dockerfile
diff options
context:
space:
mode:
authorAnthony Metzidis <anthony.metzidis@gmail.com>2019-02-06 17:01:26 -0800
committerAnthony Metzidis <anthony.metzidis@gmail.com>2019-02-22 11:53:17 -0800
commit075b17ee1d621e0ebbcecf1063f8f68a00ac221a (patch)
tree965a35e6c29ab1d842e9bf9e9300e98610446a64 /Dockerfile
parentb4148cd1d9ea889b81070d3e84a37bd5d23e5746 (diff)
Support Docker args TAGS, WORKDIR, CGO; speed up repetitive builds
Diffstat (limited to 'Dockerfile')
-rwxr-xr-xDockerfile26
1 files changed, 16 insertions, 10 deletions
diff --git a/Dockerfile b/Dockerfile
index 2cd4a14d6..01132e33e 100755
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,25 +2,31 @@
# Twitter: https://twitter.com/gohugoio
# Website: https://gohugo.io/
-FROM golang:1.11-alpine3.7 AS build
+FROM golang:1.11-stretch AS build
-ENV CGO_ENABLED=0
-ENV GOOS=linux
-ENV GO111MODULE=on
WORKDIR /go/src/github.com/gohugoio/hugo
-RUN apk add --no-cache \
- git \
- musl-dev
+RUN apt-get install \
+ git gcc g++ binutils
COPY . /go/src/github.com/gohugoio/hugo/
-RUN go install -ldflags '-s -w'
+ENV GO111MODULE=on
+RUN go get -d .
+
+ARG CGO=0
+ENV CGO_ENABLED=${CGO}
+ENV GOOS=linux
+
+# default non-existent build tag so -tags always has an arg
+ARG BUILD_TAGS="99notag"
+RUN go install -ldflags '-w -extldflags "-static"' -tags ${BUILD_TAGS}
# ---
FROM scratch
COPY --from=build /go/bin/hugo /hugo
-WORKDIR /site
-VOLUME /site
+ARG WORKDIR="/site"
+WORKDIR ${WORKDIR}
+VOLUME ${WORKDIR}
EXPOSE 1313
ENTRYPOINT [ "/hugo" ]
CMD [ "--help" ]