forked from tiangolo/uwsgi-nginx-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
77 lines (71 loc) · 6.18 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!groovy
def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, imagePullSecrets: ["regsecret"], containers: [
containerTemplate(name: 'docker', image: 'docker', ttyEnabled: true, command: 'cat',
envVars: [containerEnvVar(key: 'DOCKER_CONFIG', value: '/tmp/'),])],
volumes: [secretVolume(secretName: 'jenkins-docker-secret', mountPath: '/var/run/secrets/registry-account/'),
hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')
]) {
node(label) {
def app
def DOCKER_HUB_ACCOUNT = 'docker.env.liquidvu.com'
def DOCKER_IMAGE_NAME = 'liquid-uswg-nginx-jenkins'
def BUILD_NUM = new Date().format("'v'yyyyMMddHHmmssSSS")
stage('Clone repository') {
/* Let's make sure we have the repository cloned to our workspace */
checkout scm
}
container('docker') {
stage('Docker Build & Push Current & Latest Versions') {
sh ("""
#!/bin/bash
set +x
DOCKER_USER=`cat /var/run/secrets/registry-account/username`
DOCKER_PASSWORD=`cat /var/run/secrets/registry-account/password`
docker login -u=\${DOCKER_USER} -p=\${DOCKER_PASSWORD} ${DOCKER_HUB_ACCOUNT}
set -x
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7 -f python2.7/Dockerfile --build-arg build_num=${BUILD_NUM} ./python2.7/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7 ${DOCKER_HUB_ACCOUNT}/python2.7
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7-alpine3.7 -f python2.7-alpine3.7/Dockerfile --build-arg build_num=${BUILD_NUM} ./python2.7-alpine3.7/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7-alpine3.7
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7-alpine3.7 ${DOCKER_HUB_ACCOUNT}/python2.7-alpine3.7
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7-alpine3.7
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7-alpine3.8 -f python2.7-alpine3.8/Dockerfile --build-arg build_num=${BUILD_NUM} ./python2.7-alpine3.8/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7-alpine3.8
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7-alpine3.8 ${DOCKER_HUB_ACCOUNT}/python2.7-alpine3.8
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python2.7-alpine3.8
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.5 -f python3.5/Dockerfile --build-arg build_num=${BUILD_NUM} ./python3.5/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.5
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.5 ${DOCKER_HUB_ACCOUNT}/python3.5
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.5
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6 -f python3.6/Dockerfile --build-arg build_num=${BUILD_NUM} ./python3.6/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6 ${DOCKER_HUB_ACCOUNT}/python3.6
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6-alpine3.7 -f python3.6-alpine3.7/Dockerfile --build-arg build_num=${BUILD_NUM} ./python3.6-alpine3.7/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6-alpine3.7
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6-alpine3.7 ${DOCKER_HUB_ACCOUNT}/python3.6-alpine3.7
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6-alpine3.7
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6-alpine3.8 -f python3.6-alpine3.8/Dockerfile --build-arg build_num=${BUILD_NUM} ./python3.6-alpine3.8/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6-alpine3.8
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6-alpine3.8 ${DOCKER_HUB_ACCOUNT}/python3.6-alpine3.8
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.6-alpine3.8
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7 -f python3.7/Dockerfile --build-arg build_num=${BUILD_NUM} ./python3.7/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7 ${DOCKER_HUB_ACCOUNT}/python3.7
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7-alpine3.7 -f python3.7-alpine3.7/Dockerfile --build-arg build_num=${BUILD_NUM} ./python3.7-alpine3.7/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7-alpine3.7
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7-alpine3.7 ${DOCKER_HUB_ACCOUNT}/python3.7-alpine3.7
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7-alpine3.7
docker build -t ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7-alpine3.8 -f python3.7-alpine3.8/Dockerfile --build-arg build_num=${BUILD_NUM} ./python3.7-alpine3.8/
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7-alpine3.8
docker tag ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7-alpine3.8 ${DOCKER_HUB_ACCOUNT}/python3.7-alpine3.8
docker push ${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:python3.7-alpine3.8
""")
}
}
}
}