-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
82 lines (63 loc) · 2.29 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Hugo version... can be overridden at image build time with --build-arg
ARG HUGO_VERSION=0.92.2
# remove/comment the following line completely to compile vanilla Hugo:
# ARG HUGO_BUILD_TAGS=extended
# Hugo >= v0.81.0 requires Go 1.16+ to build
ARG GO_VERSION=1.16
# ---
FROM golang:${GO_VERSION}-alpine3.13 AS build
# renew global args from above
# https://docs.docker.com/engine/reference/builder/#scope
ARG HUGO_VERSION
# ARG HUGO_BUILD_TAGS
ARG CGO=1
ENV CGO_ENABLED=${CGO}
ENV GOOS=linux
ENV GO111MODULE=on
WORKDIR /go/src/github.com/gohugoio/hugo
RUN apk add --update --no-cache \
musl-dev \
git && \
go get github.com/magefile/mage
# clone source:
RUN git clone \
--branch "v${HUGO_VERSION}" \
--single-branch \
--depth 1 \
https://github.com/gohugoio/hugo.git ./
RUN mage -v hugo && mage install
# fix potential stack size problems on Alpine
# https://github.com/microsoft/vscode-dev-containers/blob/fb63f7e016877e13535d4116b458d8f28012e87f/containers/hugo/.devcontainer/Dockerfile#L19
RUN go get github.com/yaegashi/muslstack && \
muslstack -s 0x800000 /go/bin/hugo
# ---
FROM alpine:3.13
# renew global args from above & pin any dependency versions
ARG HUGO_VERSION
LABEL repository="https://github.com/moeb98/moe-hugo/"
LABEL homepage="https://github.com/moeb98/moe-hugo/"
LABEL org.opencontainers.image.authors="Mario Eberlein<[email protected]>"
LABEL org.opencontainers.image.title=moe-hugo
LABEL org.opencontainers.image.source="https://github.com/moeb98/moe-hugo/"
LABEL org.opencontainers.image.description="multi-arch hugo docker image"
LABEL org.opencontainers.image.version="${HUGO_VERSION}"
LABEL org.opencontainers.image.licenses="Apache 2.0"
# bring over patched binary from build stage
COPY --from=build /go/bin/hugo /usr/bin/hugo
# this step is intentionally a bit of a mess to minimize the number of layers in the final image
RUN set -euo pipefail && \
apk add --update --no-cache \
git && \
# update-ca-certificates && \
# clean up some junk
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* && \
# make super duper sure that everything went OK, exit otherwise
hugo env
# && \
# go version
# add site source as volume
VOLUME /src
WORKDIR /src
# expose live-refresh server on default port
EXPOSE 1313
ENTRYPOINT ["hugo"]