-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
follow hugo best practices and use a dedicated webserver for static a…
…ssets (#742)
- Loading branch information
Aaron Hurt
authored
Jan 22, 2020
1 parent
f4b19d9
commit b4ff0ae
Showing
1 changed file
with
21 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
FROM alpine:latest | ||
MAINTAINER Aaron Hurt <ahurt@ena.com> | ||
FROM alpine:latest AS build | ||
|
||
ARG hugo_version=0.62.2 | ||
EXPOSE 1313 | ||
|
||
## install hugo and other needed packages | ||
RUN apk update && \ | ||
apk add --no-cache ca-certificates && \ | ||
wget -q -O - \ | ||
## fetch and install hugo | ||
RUN wget -q -O - \ | ||
https://github.com/gohugoio/hugo/releases/download/v${hugo_version}/hugo_${hugo_version}_Linux-64bit.tar.gz \ | ||
| tar -zxf - hugo && \ | ||
mv hugo /usr/local/bin/hugo && \ | ||
chmod 0755 /usr/local/bin/hugo | ||
|
||
## populate hugo source | ||
COPY docs /srv | ||
## generate static content | ||
COPY docs /opt/docs | ||
WORKDIR /opt/docs | ||
RUN /usr/local/bin/hugo --buildDrafts --cleanDestinationDir --destination /opt/output | ||
|
||
FROM alpine:latest | ||
|
||
## install thttpd (http://acme.com/software/thttpd/) | ||
RUN apk add --no-cache thttpd | ||
|
||
## copy static assets form build | ||
COPY --from=build /opt/output /var/www/http | ||
|
||
## setup hugo resource cache | ||
RUN mkdir -p /srv/resources && \ | ||
chown nobody:nobody /srv/resources | ||
## use package user | ||
USER thttpd | ||
|
||
## do not run as root | ||
USER nobody | ||
EXPOSE 1180 | ||
|
||
## launch hugo and serve docs | ||
ENTRYPOINT ["/usr/local/bin/hugo"] | ||
CMD ["serve", "--disableFastRender", "--bind", "0.0.0.0", "--source", "/srv"] | ||
## launch thttpd to serve static content | ||
ENTRYPOINT ["/usr/sbin/thttpd"] | ||
CMD ["-p", "1180", "-d", "/var/www/http", "-l", "/dev/stdout", "-D"] |