From 975c948444e6275b8f7287972408697af023526f Mon Sep 17 00:00:00 2001 From: Collin Herber Date: Wed, 10 Jul 2024 12:35:08 -0400 Subject: [PATCH] chore(ci): swap to static site generation --- Dockerfile | 17 +++++++++-------- nginx.conf | 25 +++++++++++++++++++++++++ package.json | 1 + pnpm-lock.yaml | 12 ++++++++++++ src/routes/+layout.svelte | 3 +++ svelte.config.js | 12 ++++++++++-- 6 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 62ee87d..35dbcc1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ -FROM node:20-alpine -WORKDIR /app -COPY . ./ -RUN npm install -g pnpm -RUN pnpm install -RUN pnpm run build +# production stage +FROM nginx:alpine as production-stage -EXPOSE 3000 +COPY nginx.conf /etc/nginx/nginx.conf +WORKDIR /usr/share/nginx/html -CMD ["npm", "run", "start"] \ No newline at end of file +COPY build/ . + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..00e2aa9 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,25 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + server { + listen 80; + server_name pathofterraria.com; + + root /usr/share/nginx/html; + index index.html index.htm; + include /etc/nginx/mime.types; + + gzip on; + gzip_min_length 1000; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; + + location / { + try_files $uri $uri/ /index.html; + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index ef6c5fd..d30c132 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@sveltejs/adapter-auto": "3.2.2", "@sveltejs/kit": "2.5.18", "@sveltejs/vite-plugin-svelte": "^3.1.1", + "@sveltejs/adapter-static": "^3.0.2", "axios": "^1.7.2", "autoprefixer": "^10.4.19", "flowbite": "^2.4.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f8fcc05..d6893b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@sveltejs/adapter-auto': specifier: 3.2.2 version: 3.2.2(@sveltejs/kit@2.5.18(@sveltejs/vite-plugin-svelte@3.1.1(svelte@5.0.0-next.180)(vite@5.3.3))(svelte@5.0.0-next.180)(vite@5.3.3)) + '@sveltejs/adapter-static': + specifier: ^3.0.2 + version: 3.0.2(@sveltejs/kit@2.5.18(@sveltejs/vite-plugin-svelte@3.1.1(svelte@5.0.0-next.180)(vite@5.3.3))(svelte@5.0.0-next.180)(vite@5.3.3)) '@sveltejs/kit': specifier: 2.5.18 version: 2.5.18(@sveltejs/vite-plugin-svelte@3.1.1(svelte@5.0.0-next.180)(vite@5.3.3))(svelte@5.0.0-next.180)(vite@5.3.3) @@ -390,6 +393,11 @@ packages: peerDependencies: '@sveltejs/kit': ^2.0.0 + '@sveltejs/adapter-static@3.0.2': + resolution: {integrity: sha512-/EBFydZDwfwFfFEuF1vzUseBoRziwKP7AoHAwv+Ot3M084sE/HTVBHf9mCmXfdM9ijprY5YEugZjleflncX5fQ==} + peerDependencies: + '@sveltejs/kit': ^2.0.0 + '@sveltejs/kit@2.5.18': resolution: {integrity: sha512-+g06hvpVAnH7b4CDjhnTDgFWBKBiQJpuSmQeGYOuzbO3SC3tdYjRNlDCrafvDtKbGiT2uxY5Dn9qdEUGVZdWOQ==} engines: {node: '>=18.13'} @@ -1625,6 +1633,10 @@ snapshots: '@sveltejs/kit': 2.5.18(@sveltejs/vite-plugin-svelte@3.1.1(svelte@5.0.0-next.180)(vite@5.3.3))(svelte@5.0.0-next.180)(vite@5.3.3) import-meta-resolve: 4.1.0 + '@sveltejs/adapter-static@3.0.2(@sveltejs/kit@2.5.18(@sveltejs/vite-plugin-svelte@3.1.1(svelte@5.0.0-next.180)(vite@5.3.3))(svelte@5.0.0-next.180)(vite@5.3.3))': + dependencies: + '@sveltejs/kit': 2.5.18(@sveltejs/vite-plugin-svelte@3.1.1(svelte@5.0.0-next.180)(vite@5.3.3))(svelte@5.0.0-next.180)(vite@5.3.3) + '@sveltejs/kit@2.5.18(@sveltejs/vite-plugin-svelte@3.1.1(svelte@5.0.0-next.180)(vite@5.3.3))(svelte@5.0.0-next.180)(vite@5.3.3)': dependencies: '@sveltejs/vite-plugin-svelte': 3.1.1(svelte@5.0.0-next.180)(vite@5.3.3) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 36a97cd..c64abaa 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,4 +1,7 @@