diff --git a/Jenkinsfile b/Jenkinsfile index c4d8b0940..3f08d4f5d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,20 @@ -#!groovy +#!/usr/bin/env groovy + +import groovy.json.*; def image; def branchName = "${env.BRANCH_NAME}"; def branchNameTest = "preprod"; def branchNameProd = "master"; def prefixDocker = "test"; -def dockerNginxName = "nginx"; -def dockerAuthName = "auth"; -def dockerSalixName = "salix" -def dockerClientName = "client" +def dockerNginxName = ["nginx", "-p 80:8080 --link test-auth:auth --link test-salix:salix --link test-client:client"] +def dockerAuthName = ["auth", "-p 3000:3000"] +def dockerSalixName = ["salix", "-p 3001:3001"] +def dockerClientName = ["client", "-p 3002:3002"] + def buildNumber = "${env.BUILD_NUMBER}"; -String[] dockers = [dockerNginxName, dockerAuthName, dockerSalixName, dockerClientName]; + +def dockers = [dockerAuthName, dockerSalixName, dockerClientName, dockerNginxName] node { @@ -25,9 +29,11 @@ node { sh "gulp build" } - for (int i = 0; i < dockers.size(); i++) + for (int i = 0; i < dockers.size(); i++) { - def element = dockers[i]; + def element = dockers[i][0] + def ports = dockers[i][1] + stage ("docker ${element}") { stage ("Stopping ${prefixDocker}-${element} actual") @@ -38,8 +44,9 @@ node { echo "${returnDocker}"; returnDocker = sh (script: "docker rm ${prefixDocker}-${element}", returnStdout: true).trim(); echo "${returnDocker}"; - returnDocker = sh (script: "docker -force rmi ${prefixDocker}-${element}:${buildNumber-1}", returnStdout: true).trim(); - echo "${returnDocker}"; + //returnDocker = sh (script: "docker rmi ${prefixDocker}-${element}:${buildNumber-3}", returnStdout: true).trim(); + echo "borran ${prefixDocker}-${element}:${buildNumber-3}"; + //echo "${returnDocker}"; }catch(Exception _){ echo "Error Stage Stopping" } @@ -56,7 +63,7 @@ node { } } stage ("Run Docker ${element}"){ - image.run ("--name ${prefixDocker}-${element}") + image.run ("${ports} --name ${prefixDocker}-${element}") } /* stage('docker registry'){ diff --git a/services/auth/Dockerfile b/services/auth/Dockerfile index ef4e55eb2..c7f1590cc 100644 --- a/services/auth/Dockerfile +++ b/services/auth/Dockerfile @@ -8,4 +8,4 @@ RUN npm install CMD ["npm", "start"] -EXPOSE 3000:3000 +EXPOSE 3000 diff --git a/services/client/Dockerfile b/services/client/Dockerfile index 69792567d..865de516e 100644 --- a/services/client/Dockerfile +++ b/services/client/Dockerfile @@ -8,4 +8,4 @@ RUN npm install CMD ["npm", "start"] -EXPOSE 3002:3002 \ No newline at end of file +EXPOSE 3002 \ No newline at end of file diff --git a/services/nginx/Dockerfile b/services/nginx/Dockerfile index bd0d86399..727770d37 100644 --- a/services/nginx/Dockerfile +++ b/services/nginx/Dockerfile @@ -8,4 +8,4 @@ COPY conf-prod.conf /etc/nginx/nginx.conf COPY static /usr/share/nginx/html -EXPOSE 80:8080 \ No newline at end of file +EXPOSE 8080 \ No newline at end of file diff --git a/services/salix/Dockerfile b/services/salix/Dockerfile index 41cc0e1a2..9addf39cb 100644 --- a/services/salix/Dockerfile +++ b/services/salix/Dockerfile @@ -8,4 +8,4 @@ RUN npm install CMD ["npm", "start"] -EXPOSE 3001:3001 \ No newline at end of file +EXPOSE 3001 \ No newline at end of file