From b7d111866a618cfd17b7a9962df5e88fa528cd1a Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Sun, 12 Jun 2022 15:25:41 +0200 Subject: [PATCH] Add production build dockerfile --- docker/prod-host/Dockerfile | 42 +++++++++++++++++++++++++++++ docker/prod-host/nginx-server.conf | 43 ++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 docker/prod-host/Dockerfile create mode 100644 docker/prod-host/nginx-server.conf diff --git a/docker/prod-host/Dockerfile b/docker/prod-host/Dockerfile new file mode 100644 index 0000000..7f5ef41 --- /dev/null +++ b/docker/prod-host/Dockerfile @@ -0,0 +1,42 @@ +ARG HUGO_ENV=production +ARG BASE_HOST=https://www.danieldecloet.nl/ + +FROM node:18 as node-builder + +WORKDIR /code + +COPY yarn.lock /code/yarn.lock +COPY package.json /code/package.json +RUN yarn --frozen-lockfile + +COPY content/ /code/content/ +COPY docker/prod-host/search-indexer.js /code/search-indexer.js +RUN node search-indexer.js + +FROM alpine:3.16 as hugo-builder + +WORKDIR /code + +RUN apk add --no-cache hugo + +COPY config.toml /code/config.toml +COPY static/webfonts/ /code/static/webfonts/ +COPY themes/ /code/themes/ +COPY archetypes/ /code/archetypes/ +COPY assets/ /code/assets/ +COPY layouts/ /code/layouts/ +COPY data/ /code/data/ +COPY content/ /code/content/ + +COPY --from=node-builder /code/node_modules /code/node_modules +COPY --from=node-builder /code/static/js/lunr/PagesIndex.json /code/static/js/lunr/PagesIndex.json + +RUN hugo -D --minify -b "$BASE_HOST" + +FROM nginx:1.22.0-alpine + +EXPOSE 80 + +COPY docker/prod-host/nginx-server.conf /etc/nginx/conf.d/default.conf + +COPY --from=hugo-builder /code/public/ /var/www/html/ diff --git a/docker/prod-host/nginx-server.conf b/docker/prod-host/nginx-server.conf new file mode 100644 index 0000000..0d5c383 --- /dev/null +++ b/docker/prod-host/nginx-server.conf @@ -0,0 +1,43 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /var/www/html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +}