diff --git a/CHANGELOG.md b/CHANGELOG.md index 481e36a..51d7f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,3 +63,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Query execution as checkbox - Github CI - VUE_APP_PUBLIC_PATH +- Nginx conf diff --git a/Dockerfile b/Dockerfile index 855bf61..35a2fc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,29 @@ -FROM node:alpine +# Stage 1: Build the Vue application +FROM node:alpine AS build + WORKDIR /app + +# Copy package files and install dependencies COPY package.json package-lock.json ./ RUN npm install + +# Copy the rest of your application code COPY . . -RUN npm run build +# Build the Vue application +RUN npm run build:standalone + +# Stage 2: Serve the application with Nginx +FROM nginx:alpine + +# Copy the built Vue application from the previous stage +COPY --from=build /app/dist /usr/share/nginx/html + +# Copy custom Nginx configuration if needed +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Expose port 80 for the Nginx server +EXPOSE 80 -CMD npm run serve:standalone \ No newline at end of file +# Nginx will run automatically +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..0255093 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,38 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + server { + listen 80; + root /usr/share/nginx/html; + index main.ts; + 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 / { +# add_header Access-Control-Allow-Origin "${TEILER_ORCHESTRATOR_URL}"; # To be added for running within the Teiler + try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache"; + } + + location ^~ /config/ { + add_header Cache-Control "no-cache"; + add_header X-Content-Type-Options nosniff; + } + + location ~ \.(css|js|woff|woff2|png|svg|jpg|jpeg)$(.*) { + expires max; + # add_header Access-Control-Allow-Origin "${TEILER_ORCHESTRATOR_URL}"; # To be added for running within the Teiler + add_header Cache-Control "public"; + add_header X-Content-Type-Options nosniff; + } + + } +} diff --git a/package.json b/package.json index 6385405..f7079b9 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "serve": "vue-cli-service serve", "serve-https": "vue-cli-service serve --https", "build": "vue-cli-service build", + "build:standalone": "vue-cli-service build --mode standalone", "lint": "vue-cli-service lint", "serve:standalone": "vue-cli-service serve --mode standalone", "serve-https:standalone": "vue-cli-service serve --https --mode standalone"