Jenkins - Docker
This commit is contained in:
parent
27d086843f
commit
d93c6e1885
|
@ -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 {
|
||||
|
||||
|
@ -27,7 +31,9 @@ node {
|
|||
|
||||
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'){
|
||||
|
|
|
@ -8,4 +8,4 @@ RUN npm install
|
|||
|
||||
CMD ["npm", "start"]
|
||||
|
||||
EXPOSE 3000:3000
|
||||
EXPOSE 3000
|
||||
|
|
|
@ -8,4 +8,4 @@ RUN npm install
|
|||
|
||||
CMD ["npm", "start"]
|
||||
|
||||
EXPOSE 3002:3002
|
||||
EXPOSE 3002
|
|
@ -8,4 +8,4 @@ COPY conf-prod.conf /etc/nginx/nginx.conf
|
|||
|
||||
COPY static /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80:8080
|
||||
EXPOSE 8080
|
|
@ -8,4 +8,4 @@ RUN npm install
|
|||
|
||||
CMD ["npm", "start"]
|
||||
|
||||
EXPOSE 3001:3001
|
||||
EXPOSE 3001
|
Loading…
Reference in New Issue