#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 node_modules
front front
services 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 WORKDIR /salix
COPY package.json . COPY package.json .
@ -9,17 +19,12 @@ RUN npm install --only=prod
COPY loopback loopback COPY loopback loopback
COPY back back COPY back back
COPY dist dist
COPY modules modules COPY modules modules
COPY dist/webpack-assets.json dist/
COPY \ COPY \
modules.yml \ modules.yml \
LICENSE \ LICENSE \
README.md \ README.md \
./ ./
WORKDIR /etc/nginx CMD pm2-docker ./loopback/server/server.js
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

15
Jenkinsfile vendored
View File

@ -1,6 +1,7 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
env.COMPOSER_HTTP_TIMEOUT = 300; env.COMPOSE_HTTP_TIMEOUT = 300;
env.COMPOSE_PROJECT_NAME = salix
switch (env.BRANCH_NAME) { switch (env.BRANCH_NAME) {
case 'test': case 'test':
@ -8,7 +9,6 @@ switch (env.BRANCH_NAME) {
break; break;
case 'master': case 'master':
env.NODE_ENV = 'production' env.NODE_ENV = 'production'
env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376';
break; break;
} }
@ -30,11 +30,14 @@ node {
nodejs('node-lts') { nodejs('node-lts') {
sh "gulp build" sh "gulp build"
} }
} }
stage ('Generating new dockers') { stage ('Generating new dockers') {
sh "docker build -t vn-loopback:latest ./loopback/" sh "docker-compose build"
sh "docker-compose up -d --build"
sh "docker image prune -f" 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' version: '3.5'
services: services:
salix: app:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: services/nginx/Dockerfile
ports: ports:
- 80:80 - 5000:80
environment: image: salix:latest
NODE_ENV: '${NODE_ENV}'
container_name: salix
image: 'salix:latest'
restart: unless-stopped restart: unless-stopped
links:
- api
api:
build: .
ports:
- 3001-3003:3000
environment:
NODE_ENV: test
restart: unless-stopped
image: salix-api
volumes: volumes:
- '/config:/config' - /config:/config

View File

@ -2,15 +2,18 @@ FROM debian:stretch-slim
EXPOSE 80 EXPOSE 80
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y apt-utils \ && apt-get install -y apt-utils \
&& apt-get install -y \ && apt-get install -y --no-install-recommends nginx
curl \
gnupg2 \
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install -y \
nginx \
nodejs \
&& npm -g install pm2
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}} {{#services}}
location ~ ^/{{.}}(?:/(.*))?$ { 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}} {{/services}}
@ -18,6 +19,7 @@ server {
autoindex on; autoindex on;
} }
location ~ ^(?:/(.*))?$ { 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;
} }
} }