Docker deploy with private registry

This commit is contained in:
Juan Ferrer 2019-01-11 08:28:55 +01:00
parent 02bab99d4e
commit b6c1fd2e8e
2 changed files with 33 additions and 17 deletions

28
Jenkinsfile vendored
View File

@ -32,25 +32,41 @@ try {
}
}
stage ('Deploy') {
withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) {
env.COMPOSE_PROJECT_NAME = env.JOB_NAME.replace('/', '-');
env.TAG = env.BRANCH_NAME
switch (env.BRANCH_NAME) {
case 'master':
env.PORT = 5000
env.PORT = 5002
break;
case 'test':
env.PORT = 5001
break;
}
env.COMPOSE_PROJECT_NAME = env.JOB_NAME.replace('/', '-');
withCredentials([usernamePassword(
credentialsId: 'docker-registry',
usernameVariable: 'USER',
passwordVariable: 'PASSWORD')
]) {
env.REGISTRY = 'registry.verdnatura.es'
sh "docker login --username \"${env.USER}\" --password \"${env.PASSWORD}\" ${env.REGISTRY}"
sh "docker-compose build --parallel"
sh "docker-compose push"
sh "docker logout ${env.REGISTRY}"
}
withCredentials([dockerCert(
credentialsId: 'docker',
variable: 'DOCKER_CERT_PATH')
]) {
env.DOCKER_TLS_VERIFY = 1
env.TAG = env.BRANCH_NAME
env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376';
sh "docker-compose up --build -d"
sh "docker-compose up -d"
env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376';
sh "docker-compose up --build -d"
sh "docker-compose up -d"
}
}
}

View File

@ -1,20 +1,20 @@
version: '3.5'
services:
app:
image: registry.verdnatura.es/salix-app:${TAG}
restart: unless-stopped
build:
context: .
dockerfile: services/nginx/Dockerfile
ports:
- ${PORT}:80
image: salix-app:${TAG}
restart: unless-stopped
links:
- api
api:
image: registry.verdnatura.es/salix-api:${TAG}
restart: unless-stopped
build: .
environment:
- NODE_ENV
restart: unless-stopped
image: salix-api:${TAG}
volumes:
- /containers/salix:/etc/salix