mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
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
This commit is contained in:
parent
9f27091e10
commit
8531ec7ca3
2 changed files with 27 additions and 15 deletions
8
.dockerignore
Normal file
8
.dockerignore
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
*.md
|
||||||
|
*.log
|
||||||
|
*.txt
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
.circleci
|
||||||
|
docs
|
||||||
|
examples
|
34
Dockerfile
34
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
|
FROM golang:1.10.0-alpine3.7 AS build
|
||||||
RUN go get github.com/golang/dep/cmd/dep
|
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
ENV GOOS=linux
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/gohugoio/hugo
|
WORKDIR /go/src/github.com/gohugoio/hugo
|
||||||
ADD . /go/src/github.com/gohugoio/hugo/
|
RUN apk add --no-cache \
|
||||||
RUN dep ensure
|
git \
|
||||||
RUN go install -ldflags '-s -w'
|
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 && \
|
FROM scratch
|
||||||
apk add --no-cache \
|
COPY --from=build /go/bin/hugo /hugo
|
||||||
dumb-init
|
|
||||||
COPY --from=build /go/bin/hugo /bin/hugo
|
|
||||||
USER hugo
|
|
||||||
WORKDIR /site
|
WORKDIR /site
|
||||||
VOLUME /site
|
VOLUME /site
|
||||||
EXPOSE 1313
|
EXPOSE 1313
|
||||||
|
ENTRYPOINT [ "/hugo" ]
|
||||||
ENTRYPOINT ["/usr/bin/dumb-init", "--", "hugo"]
|
|
||||||
CMD [ "--help" ]
|
CMD [ "--help" ]
|
||||||
|
|
Loading…
Reference in a new issue