-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
49 lines (39 loc) · 1.69 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
# use intranet-baseimage with hugo, npm extended image for building in build step
# the base image also includes installed NPM packages and the Hugo theme(s)
FROM gsoci.azurecr.io/giantswarm/intranet-baseimage:0.2.415 AS build
# refresh relevant files (without clobbering stuff in the baseimage)
COPY .git /src/.git/
COPY assets /src/assets/
COPY content /src/content/
COPY layouts /src/layouts/
COPY static /src/static/
COPY config.toml /src/config.toml
# build static site
RUN hugo --logLevel info --gc --minify --enableGitInfo --cleanDestinationDir --destination /src/public
# final hugo output polished exclusively for production (static files served by nginx)
FROM build AS build-production
# Compress files using gzip
# (creates a copy and leaves the uncompressed version in place)
RUN find /src/public \
-type f -regextype posix-extended \
-iregex '.*\.(css|csv|html?|js|svg|txt|xml|json|webmanifest|ttf)' | \
xargs gzip -9 -k
# Remove uncompressed HTML files
# to reduce storage requirements and image size.
RUN find /src/public \
-type f \
-name 'index.html' \
-delete
# use minimal nginx alpine image for serving static html
FROM gsoci.azurecr.io/giantswarm/nginx-unprivileged:1.27-alpine
EXPOSE 8080
USER 0
# Delete default config (which we have no control over)
RUN rm -r /etc/nginx/conf.d && rm /etc/nginx/nginx.conf
# The custom config enables the /searchapi route, proxying to sitesearch-app.docs:9200
COPY proxy/proxy-production.default.conf /etc/nginx/nginx.conf
# Ensure tmp dir exists and has right ownership
RUN mkdir -p /tmp/nginx && chown -R 101 /tmp/nginx
# copy in staticly built hugo site from build step above
COPY --from=build-production /src/public /usr/share/nginx/html
USER 101