Hello,
I have two servers as follows:
GitLab: GitLab Server
Runner: Docker and GitLab-Runner
I created a Node.js file on the GitLab server and I want to run this file through Nginx and Node.js containers. I know that I should have two Dockerfile and .gitlab-ci.yml files on the GitLab server.
The Dockerfile
is as follows:
FROM node:latest as build-stage
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package*.json /usr/src/app/package.json
RUN npm install
RUN npm update
COPY . /usr/src/app
EXPOSE 3000
#production stage
FROM nginx:latest as production-stage
COPY --from=build-stage /usr/src/app /usr/share/nginx/html
COPY ./cfiles/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD nginx -g 'daemon off;'
The default.conf
is as follows:
upstream nodejs {
server nodejs:3000;
}
server {
listen 80;
server_name default_server;
error_log /var/log/nginx/error.system-default.log;
access_log /var/log/nginx/access.system-default.log;
charset utf-8;
root /usr/share/nginx/html;
index index.html index.php index.js;
location ~ \.js$ {
proxy_pass http://nodejs;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location / {
autoindex on;
try_files $uri $uri/ $uri.html =404;
}
}
But I don’t know what to do about the .gitlab-ci.yml file. I searched the internet for examples, but none of them related to what I want to do.
Please advice me.
Thank you.