diff --git a/docker/Dockerfile b/docker/Dockerfile index bf598073..13949801 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -15,7 +15,7 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ pnpm install --frozen-lockfile --ignore-scripts # Copy necessary build configurations -COPY vite.config.ts index.html tsconfig.json tsconfig.app.json tsconfig.node.json /website/ +COPY vite.config.ts index.html tsconfig.json tsconfig.app.json tsconfig.node.json docker/nginx.conf /website/ COPY public /website/public COPY src /website/src @@ -24,13 +24,16 @@ RUN pnpm run build FROM nginxinc/nginx-unprivileged:stable-alpine-perl +ENV NGINX_ENTRYPOINT_QUIET_LOGS=1 + COPY --from=build /website/dist /usr/share/nginx/html +COPY --from=build /website/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 8080 CMD ["nginx", "-g", "daemon off;"] -HEALTHCHECK --interval=5m --timeout=3s CMD ["curl", "-f" , "http://localhost:8080/", "||", "exit 1"] +HEALTHCHECK --interval=5m --timeout=3s CMD curl -fsS http://localhost:8080/ || exit 1 LABEL org.opencontainers.image.title="Chapter-Website" LABEL org.opencontainers.image.description="ACM @ UC Merced's website" diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 00000000..28629adc --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,48 @@ +map $uri $cache_control { + default "public, max-age=86400"; + ~^/assets/ "public, max-age=31536000, immutable"; + ~^/workbox-[^/]+\.js$ "public, max-age=31536000, immutable"; + /index.html "no-cache"; + /sw.js "no-cache"; + /registerSW.js "no-cache"; +} + +server { + listen 8080; + listen [::]:8080; + + root /usr/share/nginx/html; + index index.html; + + charset utf-8; + server_tokens off; + absolute_redirect off; + + gzip on; + gzip_vary on; + gzip_comp_level 6; + gzip_min_length 1024; + gzip_static on; + gzip_types text/css text/plain text/xml application/javascript application/json + application/manifest+json image/svg+xml; + + add_header Cache-Control $cache_control always; + add_header X-Content-Type-Options "nosniff" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + add_header X-Frame-Options "SAMEORIGIN" always; + + location = /site.webmanifest { + types { } + default_type application/manifest+json; + } + + location ^~ /assets/ { + try_files $uri =404; + } + + location / { + try_files $uri $uri/ /index.html; + } + + include /etc/nginx/extra-conf.d/*.conf; +}