Skip to content

Commit 075b17e

Browse files
committed
Support Docker args TAGS, WORKDIR, CGO; speed up repetitive builds
1 parent b4148cd commit 075b17e

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
.circleci
77
docs
88
examples
9+
Dockerfile

Dockerfile

+16-10
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,31 @@
22
# Twitter: https://twitter.com/gohugoio
33
# Website: https://gohugo.io/
44

5-
FROM golang:1.11-alpine3.7 AS build
5+
FROM golang:1.11-stretch AS build
66

7-
ENV CGO_ENABLED=0
8-
ENV GOOS=linux
9-
ENV GO111MODULE=on
107

118
WORKDIR /go/src/github.com/gohugoio/hugo
12-
RUN apk add --no-cache \
13-
git \
14-
musl-dev
9+
RUN apt-get install \
10+
git gcc g++ binutils
1511
COPY . /go/src/github.com/gohugoio/hugo/
16-
RUN go install -ldflags '-s -w'
12+
ENV GO111MODULE=on
13+
RUN go get -d .
14+
15+
ARG CGO=0
16+
ENV CGO_ENABLED=${CGO}
17+
ENV GOOS=linux
18+
19+
# default non-existent build tag so -tags always has an arg
20+
ARG BUILD_TAGS="99notag"
21+
RUN go install -ldflags '-w -extldflags "-static"' -tags ${BUILD_TAGS}
1722

1823
# ---
1924

2025
FROM scratch
2126
COPY --from=build /go/bin/hugo /hugo
22-
WORKDIR /site
23-
VOLUME /site
27+
ARG WORKDIR="/site"
28+
WORKDIR ${WORKDIR}
29+
VOLUME ${WORKDIR}
2430
EXPOSE 1313
2531
ENTRYPOINT [ "/hugo" ]
2632
CMD [ "--help" ]

0 commit comments

Comments
 (0)