mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Support Docker args TAGS, WORKDIR, CGO; speed up repetitive builds
This commit is contained in:
parent
b4148cd1d9
commit
075b17ee1d
2 changed files with 17 additions and 10 deletions
|
@ -6,3 +6,4 @@
|
||||||
.circleci
|
.circleci
|
||||||
docs
|
docs
|
||||||
examples
|
examples
|
||||||
|
Dockerfile
|
||||||
|
|
26
Dockerfile
26
Dockerfile
|
@ -2,25 +2,31 @@
|
||||||
# Twitter: https://twitter.com/gohugoio
|
# Twitter: https://twitter.com/gohugoio
|
||||||
# Website: https://gohugo.io/
|
# 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
|
WORKDIR /go/src/github.com/gohugoio/hugo
|
||||||
RUN apk add --no-cache \
|
RUN apt-get install \
|
||||||
git \
|
git gcc g++ binutils
|
||||||
musl-dev
|
|
||||||
COPY . /go/src/github.com/gohugoio/hugo/
|
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
|
FROM scratch
|
||||||
COPY --from=build /go/bin/hugo /hugo
|
COPY --from=build /go/bin/hugo /hugo
|
||||||
WORKDIR /site
|
ARG WORKDIR="/site"
|
||||||
VOLUME /site
|
WORKDIR ${WORKDIR}
|
||||||
|
VOLUME ${WORKDIR}
|
||||||
EXPOSE 1313
|
EXPOSE 1313
|
||||||
ENTRYPOINT [ "/hugo" ]
|
ENTRYPOINT [ "/hugo" ]
|
||||||
CMD [ "--help" ]
|
CMD [ "--help" ]
|
||||||
|
|
Loading…
Reference in a new issue