From e3c3e599e9127f9aafc7ba851d7a5789c3a876a2 Mon Sep 17 00:00:00 2001 From: Ellie Leijten Date: Mon, 4 Dec 2023 19:39:40 +0100 Subject: [PATCH] Updated CI and nginx.conf for Svelte port --- dockerfile | 25 +++++++++++++++++++------ nginx.conf | 19 ------------------- package-lock.json | 4 ++-- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/dockerfile b/dockerfile index 155071b..0ef7583 100644 --- a/dockerfile +++ b/dockerfile @@ -1,15 +1,28 @@ +# Use a Node.js image to build the Svelte application +FROM node:16 AS build + +WORKDIR /app + +# Copy package.json and package-lock.json (if available) +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of your app's source code +COPY . . + +# Build the app +RUN npm run build + # Use the official NGINX image as the base FROM nginx # Copy the nginx.conf file to the appropriate location COPY nginx.conf /etc/nginx/nginx.conf -# Install dependencies and compile project -run npm install -run npm run build - -# Copy the files from the src folder to the NGINX document root -COPY build /usr/share/nginx/html +# Copy the built application from the first stage +COPY --from=build /app/build /usr/share/nginx/html # Add a script that will generate the .htpasswd file COPY generate-htpasswd.sh /usr/local/bin/ diff --git a/nginx.conf b/nginx.conf index 704cf9d..84daf0c 100644 --- a/nginx.conf +++ b/nginx.conf @@ -17,25 +17,6 @@ http { try_files $uri $uri/ =404; } - location ~* \.(css|js)$ { - root /usr/share/nginx/html; - try_files $uri =404; - expires 1y; - add_header Cache-Control "public"; - } - - location ~* \.(jpg|jpeg|png|gif|ico|svg|webp|mp3|wav|ogg)$ { - root /usr/share/nginx/html; - try_files $uri =404; - expires 1y; - add_header Cache-Control "public"; - } - - location = /favicon.ico { - root /usr/share/nginx/html; - try_files $uri =404; - } - location ~* ^/userinfo$ { auth_basic "Restricted Content"; auth_basic_user_file /etc/nginx/.htpasswd; diff --git a/package-lock.json b/package-lock.json index 1443b88..b5289c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "raibu-web", - "version": "0.0.1", + "version": "1.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "raibu-web", - "version": "0.0.1", + "version": "1.1.1", "devDependencies": { "@sveltejs/adapter-static": "^2.0.3", "@sveltejs/kit": "^1.27.4",