#814 Docker deploy fixes

This commit is contained in:
Juan Ferrer 2018-12-31 14:02:46 +01:00
parent c468367d1f
commit 756b5a82ff
6 changed files with 55 additions and 35 deletions

View File

@ -1,4 +1,4 @@
node_modules
front
services
!services/nginx/temp/nginx.conf
!services/nginx

View File

@ -1,6 +1,16 @@
FROM vn-node
FROM debian:stretch-slim
ENV NODE_ENV test
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y apt-utils \
&& apt-get install -y \
curl \
gnupg2 \
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install -y \
nodejs \
&& npm -g install pm2
WORKDIR /salix
COPY package.json .
@ -9,17 +19,12 @@ RUN npm install --only=prod
COPY loopback loopback
COPY back back
COPY dist dist
COPY modules modules
COPY dist/webpack-assets.json dist/
COPY \
modules.yml \
LICENSE \
README.md \
./
WORKDIR /etc/nginx
COPY services/nginx/temp/nginx.conf sites-available/salix
RUN rm sites-enabled/default && ln -s ../sites-available/salix sites-enabled/salix
WORKDIR /salix
CMD service nginx start && pm2-docker ./loopback/server/server.js
CMD pm2-docker ./loopback/server/server.js

15
Jenkinsfile vendored
View File

@ -1,6 +1,7 @@
#!/usr/bin/env groovy
env.COMPOSER_HTTP_TIMEOUT = 300;
env.COMPOSE_HTTP_TIMEOUT = 300;
env.COMPOSE_PROJECT_NAME = salix
switch (env.BRANCH_NAME) {
case 'test':
@ -8,7 +9,6 @@ switch (env.BRANCH_NAME) {
break;
case 'master':
env.NODE_ENV = 'production'
env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376';
break;
}
@ -30,11 +30,14 @@ node {
nodejs('node-lts') {
sh "gulp build"
}
}
stage ('Generating new dockers') {
sh "docker build -t vn-loopback:latest ./loopback/"
sh "docker-compose up -d --build"
sh "docker image prune -f"
sh "docker-compose build"
env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376';
sh "docker-compose up -d"
env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376';
sh "docker-compose up -d"
}
}

View File

@ -1,15 +1,22 @@
version: '3.5'
services:
salix:
app:
build:
context: .
dockerfile: Dockerfile
dockerfile: services/nginx/Dockerfile
ports:
- 80:80
environment:
NODE_ENV: '${NODE_ENV}'
container_name: salix
image: 'salix:latest'
- 5000:80
image: salix:latest
restart: unless-stopped
links:
- api
api:
build: .
ports:
- 3001-3003:3000
environment:
NODE_ENV: test
restart: unless-stopped
image: salix-api
volumes:
- '/config:/config'
- /config:/config

View File

@ -2,15 +2,18 @@ FROM debian:stretch-slim
EXPOSE 80
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y apt-utils \
&& apt-get install -y \
curl \
gnupg2 \
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install -y \
nginx \
nodejs \
&& npm -g install pm2
&& apt-get install -y --no-install-recommends nginx
CMD ["bash"]
WORKDIR /etc/nginx
COPY services/nginx/temp/nginx.conf sites-available/salix
RUN rm sites-enabled/default && ln -s ../sites-available/salix sites-enabled/salix
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
COPY dist /salix/dist
CMD ["nginx", "-g", "daemon off;"]

View File

@ -9,7 +9,8 @@ server {
{{#services}}
location ~ ^/{{.}}(?:/(.*))?$ {
proxy_pass http://127.0.0.1:{{defaultPort}}/$1$is_args$args;
resolver 127.0.0.11;
proxy_pass http://api:{{defaultPort}}/$1$is_args$args;
}
{{/services}}
@ -18,6 +19,7 @@ server {
autoindex on;
}
location ~ ^(?:/(.*))?$ {
proxy_pass http://127.0.0.1:{{defaultPort}}/$1$is_args$args;
resolver 127.0.0.11;
proxy_pass http://api:{{defaultPort}}/$1$is_args$args;
}
}