Skip to content
Snippets Groups Projects
Commit ece6ccd1 authored by Rafael László's avatar Rafael László :speech_balloon:
Browse files

replace npm serve with nginx

parent b6a64856
No related branches found
No related tags found
No related merge requests found
image: node:latest
variables:
CONTAINER_IMAGE: 'registry.kszk.bme.hu/kszk/devteam/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME'
stages:
- Pre Build
- Docker Build
PreBuild:
stage: Pre Build
tags: [docker]
image: node:latest
script:
- npm install
- npm run build
cache:
paths:
- build/
artifacts:
expire_in: 1 day
paths:
- build/
only:
- tags
Docker build:
stage: Docker Build
tags: [docker]
......
FROM node:10-alpine
FROM nginx:1.19.2
WORKDIR /opt/app
ENV TZ Europe/Budapest
RUN apk add --no-cache tzdata && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# copy the files builded with npm run build
COPY build /var/www
COPY nginx.conf /etc/nginx/nginx.conf
# Copying application files
COPY ./src ./src
COPY ./public ./public
COPY package.json package-lock.json ./
# Installing dependencies
RUN npm install
RUN npm install serve
# Running
EXPOSE 3000
ENTRYPOINT ["npm", "run", "deploy"]
ENTRYPOINT ["nginx","-g","daemon off;"]
# auto detects a good number of processes to run
worker_processes auto;
#Provides the configuration file context in which the directives that affect connection processing are specified.
events {
# Sets the maximum number of simultaneous connections that can be opened by a worker process.
worker_connections 8000;
# Tells the worker to accept multiple connections at a time
multi_accept on;
}
http {
# what times to include
include /etc/nginx/mime.types;
# what is the default one
default_type application/octet-stream;
# Sets the path, format, and configuration for a buffered log write
log_format compression '$remote_addr - $remote_user [$time_local] '
'"$request" $status $upstream_addr '
'"$http_referer" "$http_user_agent"';
server {
# listen on port 80
listen 3000;
# save logs here
access_log /var/log/nginx/access.log compression;
# where the root here
root /var/www;
# what file to server as index
index index.html index.htm;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to redirecting to index.html
try_files $uri $uri/ /index.html;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# Javascript and CSS files
location ~* \.(?:css|js)$ {
try_files $uri =404;
expires 1y;
access_log off;
add_header Cache-Control "public";
}
# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
}
}
}
......@@ -28,8 +28,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"deploy": "serve -l 3000 -s build"
"eject": "react-scripts eject"
},
"devDependencies": {
"eslint": "6.8.0",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment