Publish the site as a container on the cluster instead of the pages branch #54
+17
-6
@@ -1,13 +1,24 @@
|
||||
# The published Atlas page as a container: build the static site (npm run build -> dist/), then serve it with an
|
||||
# unprivileged nginx on port 8080. .gitea/workflows/image.yml builds this on every push to main and pushes it to
|
||||
# harbor.kenschiano.net/home/threshing-atlas:latest; Argo CD Image Updater rolls the deployment (kubefiles,
|
||||
# web/threshing-atlas) when that digest changes.
|
||||
FROM node:22-alpine AS build
|
||||
# The published Atlas page as a container, on Red Hat's hardened images: build the static site with Node, check
|
||||
# the nginx config with the nginx builder (it has a shell), then serve with the distroless nginx runtime (no shell
|
||||
# or package manager, UID 65532, port 8080). .gitea/workflows/image.yml builds this on every push to main and
|
||||
# pushes it to harbor.kenschiano.net/home/threshing-atlas:latest; Argo CD Image Updater rolls the deployment
|
||||
# (kubefiles, web/threshing-atlas) when that digest changes.
|
||||
ARG NODE_TAG=22
|
||||
ARG NGINX_TAG=latest
|
||||
|
||||
FROM registry.access.redhat.com/hi/nodejs:${NODE_TAG}-builder AS build
|
||||
# Only /site leaves this stage, so build as root
|
||||
USER root
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN node site/build.js /site
|
||||
|
||||
FROM nginxinc/nginx-unprivileged:1.28-alpine
|
||||
# Fail the build on a bad config, since the runtime image can't run `nginx -t` for us
|
||||
FROM registry.access.redhat.com/hi/nginx:${NGINX_TAG}-builder AS nginx-check
|
||||
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
RUN nginx -t -e /dev/stderr
|
||||
|
||||
FROM registry.access.redhat.com/hi/nginx:${NGINX_TAG}
|
||||
COPY --from=nginx-check /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /site /usr/share/nginx/html
|
||||
EXPOSE 8080
|
||||
|
||||
+22
-6
@@ -1,20 +1,36 @@
|
||||
# The Atlas is plain static files. The data changes daily, so browsers revalidate rather than cache blindly.
|
||||
# Replaces the image's conf.d/default.conf (it listens on 8080 and runs as UID 65532).
|
||||
|
||||
# Temp files under /tmp (an emptyDir in the pod), so the root filesystem can be read-only
|
||||
client_body_temp_path /tmp/client_body;
|
||||
proxy_temp_path /tmp/proxy;
|
||||
fastcgi_temp_path /tmp/fastcgi;
|
||||
uwsgi_temp_path /tmp/uwsgi;
|
||||
scgi_temp_path /tmp/scgi;
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
charset utf-8;
|
||||
server_tokens off;
|
||||
|
||||
types {
|
||||
text/plain yaml py csv;
|
||||
}
|
||||
# The image logs to files under /var/log/nginx; send access logs to the pod log instead
|
||||
access_log /dev/stdout main;
|
||||
|
||||
# Show the page's data and source files as text (in server context this replaces the inherited types)
|
||||
include /etc/nginx/mime.types;
|
||||
types {
|
||||
text/plain yaml py;
|
||||
}
|
||||
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/javascript application/json text/csv;
|
||||
gzip_types text/plain text/css text/csv text/javascript application/javascript application/json;
|
||||
|
||||
add_header Cache-Control "no-cache";
|
||||
add_header Cache-Control "no-cache" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
|
||||
location = /healthz { access_log off; return 200 "ok\n"; }
|
||||
location = /healthz { access_log off; default_type text/plain; return 200 "ok\n"; }
|
||||
location / { try_files $uri $uri/ =404; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user