Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
Javi Gallego 2018-06-18 07:26:12 +02:00
commit af925de00c
26 changed files with 86 additions and 180 deletions

View File

@ -1,13 +0,0 @@
FROM node:8.9.4
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]
EXPOSE 3000

23
Jenkinsfile vendored
View File

@ -1,14 +1,8 @@
#!/usr/bin/env groovy
def branchName = env.BRANCH_NAME;
env.COMPOSER_HTTP_TIMEOUT = 300;
// TODO: We are using latest tag until image rotation it's implemented
env.TAG = 'latest' /* env.BUILD_NUMBER */;
env.BRANCH_NAME = branchName;
env.salixUser = env.salixUser;
env.salixPassword = env.salixPassword;
switch (branchName) {
switch (env.BRANCH_NAME) {
case 'test':
env.NODE_ENV = 'test';
env.salixHost = env.testSalixHost;
@ -24,24 +18,21 @@ switch (branchName) {
node {
stage ('Print environment variables') {
echo "Branch ${branchName}, tag ${env.TAG}, environament ${env.NODE_ENV}"
echo "Branch ${env.BRANCH_NAME}, build number ${env.BUILD_NUMBER}, environment ${env.NODE_ENV}"
}
stage ('Checkout') {
checkout scm
}
stage ('Install client Node dependencies') {
stage ('Install Node dependencies') {
sh "npm install"
sh "gulp install"
}
stage ('Build project') {
sh "gulp build"
}
stage ('Install services Node dependencies') {
sh "cd ./services/loopback && npm install"
}
stage ('Removing old dockers') {
sh "docker-compose down --rmi 'all'"
}
stage ('Generating new dockers') {
sh "docker build -t vn-loopback:latest ./services/loopback/"
sh "docker-compose up -d --build"
sh "docker image prune -f"
}
}

View File

@ -11,10 +11,10 @@
<vn-vertical>
<vn-auto style="position: relative" text-center>
<img
ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
zoom-image="http://verdnatura.es/vn-image-data/catalog/900x900/{{$ctrl.item.image}}"
ng-src="//verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
zoom-image="//verdnatura.es/vn-image-data/catalog/900x900/{{$ctrl.item.image}}"
on-error-src/>
<a href="https://www.verdnatura.es/#!form=admin/items&filter={{$ctrl.item.id}}" target="_blank">
<a href="//verdnatura.es/#!form=admin/items&filter={{$ctrl.item.id}}" target="_blank">
<vn-float-button
icon="edit"
style="position: absolute; margin: 1em; bottom: 0; right: 0;"

View File

@ -5,8 +5,8 @@
<vn-horizontal ng-click="$ctrl.onClick($event)">
<vn-auto class="image" margin-medium-right>
<img
ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
zoom-image="http://verdnatura.es/vn-image-data/catalog/900x900/{{::$ctrl.item.image}}"
ng-src="//verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
zoom-image="//verdnatura.es/vn-image-data/catalog/900x900/{{::$ctrl.item.image}}"
on-error-src/>
</vn-auto>
<vn-one>

View File

@ -5,8 +5,8 @@
<vn-vertical>
<vn-one>
<img
ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
zoom-image="http://verdnatura.es/vn-image-data/catalog/900x900/{{$ctrl.item.image}}" on-error-src/>
ng-src="//verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
zoom-image="//verdnatura.es/vn-image-data/catalog/900x900/{{$ctrl.item.image}}" on-error-src/>
</vn-one>
<vn-one>
<h5 text-center pad-small-v class="title">{{$ctrl.item.id}}</h5>

View File

@ -1,12 +1,10 @@
version: '2'
version: '3.5'
services:
nginx:
container_name: "${BRANCH_NAME}-nginx"
image: "nginx:${TAG}"
privileged: true
build:
context: ./services/nginx
ports:
- "80:80"
mem_limit: 200m
- 80:80
- 443:443
links: []

View File

@ -128,7 +128,6 @@ gulp.task('install', () => {
let packageFiles = [];
let services = fs.readdirSync(servicesDir);
services.push('..');
services.forEach(service => {
packageFiles.push(`${servicesDir}/${service}/package.json`);
});
@ -154,34 +153,53 @@ gulp.task('docker-compose', async () => {
let composeYml = yaml.safeLoad(compose);
let services = await getServices();
for (let service of services) {
let dockerFile = `${__dirname}/services/${service.name}/Dockerfile`;
let imageTag = 'latest';
if (process.env.BUILD_NUMBER)
imageTag = process.env.BUILD_NUMBER;
// if (await fs.exists(`./services/${service.name}/Dockerfile`))
// dockerFile = 'Dockerfile';
let namePrefix = '';
if (process.env.BRANCH_NAME)
namePrefix = `${process.env.BRANCH_NAME}-`;
for (let service of services) {
let dockerFile = `Dockerfile`;
let localDockerFile = `${__dirname}/services/${service.name}/Dockerfile`;
if (await fs.exists(localDockerFile))
dockerFile = localDockerFile;
composeYml.services[service.name] = {
environment: [
'NODE_ENV=${NODE_ENV}',
'salixHost=${salixHost}',
'salixPort=${salixPort}',
'salixUser=${salixUser}',
'salixPassword=${salixPassword}'
],
container_name: `\${BRANCH_NAME}-${service.name}`,
image: `${service.name}:\${TAG}`,
volumes: ['/config:/config'],
build: {
context: `./services`,
dockerfile: dockerFile
},
ports: [`${service.port}:${defaultPort}`]
ports: [`${service.port}:${defaultPort}`],
environment: {
NODE_ENV: '${NODE_ENV}',
salixHost: '${salixHost}',
salixPort: '${salixPort}',
salixUser: '${salixUser}',
salixPassword: '${salixPassword}'
}
};
composeYml.services.nginx.links.push(
`${service.name}:\${BRANCH_NAME}-${service.name}`
`${service.name}:${namePrefix}${service.name}`
);
}
for (let serviceName in composeYml.services) {
let service = composeYml.services[serviceName];
Object.assign(service, {
container_name: `${namePrefix}${serviceName}`,
image: `${serviceName}:${imageTag}`,
volumes: ['/config:/config']
});
service.build.labels = {
'salix.tag': imageTag
};
}
let ymlString = yaml.safeDump(composeYml);
await fs.writeFile('./docker-compose.yml', ymlString);
});
@ -193,8 +211,6 @@ gulp.task('build-clean', () => {
const del = require('del');
const files = [
`${buildDir}/*`,
`!${buildDir}/templates`,
`!${buildDir}/images`,
`docker-compose.yml`
];
return del(files, {force: true});

12
package-lock.json generated
View File

@ -8577,7 +8577,7 @@
"lodash.groupby": "4.6.0",
"p-queue": "1.2.0",
"through2": "2.0.3",
"which": "1.3.0"
"which": "1.3.1"
},
"dependencies": {
"isexe": {
@ -8597,9 +8597,9 @@
}
},
"which": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
"integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=",
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
"dev": true,
"requires": {
"isexe": "2.0.0"
@ -10827,7 +10827,6 @@
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz",
"integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==",
"dev": true,
"requires": {
"argparse": "1.0.9",
"esprima": "4.0.0"
@ -10836,8 +10835,7 @@
"esprima": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==",
"dev": true
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw=="
}
}
},

3
services/.gitignore vendored
View File

@ -1,3 +1,2 @@
datasources.test.json
datasources.development.json
datasources.*.json
db.json

View File

@ -1,3 +0,0 @@
{
"generator-loopback": {}
}

View File

@ -1,12 +1,7 @@
FROM node:8.9.4
FROM vn-loopback:latest
COPY auth /app
COPY loopback /loopback
COPY nginx/static/webpack-assets.json /loopback/client/
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,12 +1,6 @@
FROM node:8.9.4
FROM vn-loopback:latest
COPY client /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,12 +1,6 @@
FROM node:8.9.4
FROM vn-loopback:latest
COPY item /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -0,0 +1,4 @@
FROM node:8-slim
COPY . /loopback
RUN npm -g install pm2

View File

@ -1,11 +1,5 @@
FROM node:8.9.4
FROM vn-loopback:latest
COPY mailer /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,12 +1,12 @@
FROM nginx
RUN rm /etc/nginx/nginx.conf
RUN rm /etc/nginx/conf.d/default.conf
RUN rm -f /etc/nginx/nginx.conf
RUN rm -f /etc/nginx/conf.d/default.conf
COPY temp/nginx.conf /etc/nginx/nginx.conf
COPY static /usr/share/nginx/html
RUN apt-get update && apt-get -y install vim dnsmasq dnsutils iputils-ping
RUN apt-get update && apt-get -y install dnsmasq
RUN rm -fr /usr/share/dns
RUN echo listen-address=127.0.0.1 > /etc/dnsmasq.d/dnsmasq.conf

View File

@ -13,9 +13,18 @@ http {
include /etc/nginx/mime.types;
server {
listen {{port}};
server_name {{host}};
autoindex off;
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /config/nginx/cert.pem;
ssl_certificate_key /config/nginx/key.pem;
server_name {{host}};
autoindex off;
root /usr/share/nginx/html;

View File

@ -1,12 +0,0 @@
FROM node:8.9.4
COPY order /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,16 +0,0 @@
{
"name": "vn-order",
"version": "1.0.0",
"main": "server/server.js",
"scripts": {
"lint": "eslint .",
"start": "node .",
"posttest": "npm run lint && nsp check"
},
"repository": {
"type": "git",
"url": "https://git.verdnatura.es/salix"
},
"license": "GPL-3.0",
"description": "vn-order"
}

View File

@ -1,6 +0,0 @@
{
}

View File

@ -1,5 +0,0 @@
var vnLoopback = require('../../loopback/server/server.js');
var app = module.exports = vnLoopback.loopback();
vnLoopback.boot(app, __dirname, module);

View File

@ -1,11 +1,5 @@
FROM node:8.9.4
FROM vn-loopback:latest
COPY print /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,11 +1,5 @@
FROM node:8.9.4
FROM vn-loopback:latest
COPY production /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,11 +1,5 @@
FROM node:8.9.4
FROM vn-loopback:latest
COPY route /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,12 +1,6 @@
FROM node:8.9.4
FROM vn-loopback:latest
COPY salix /app
COPY loopback /loopback
COPY nginx/static/webpack-assets.json /loopback/client/
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,12 +1,5 @@
FROM node:8.9.4
FROM vn-loopback:latest
COPY ticket /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]