-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
41 lines (33 loc) · 888 Bytes
/
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
node('dockerhost') {
def dockerImage;
stage('checkout') {
checkout scm
}
docker.image('node:10.16.3').inside {
withEnv(['npm_config_cache=npm-cache', 'HOME=.']) {
stage('install') {
sh 'npm install'
}
stage('build') {
sh 'npm run build'
}
}
}
stage('containerize') {
dockerImage = docker.build("hours-and-miles:$BUILD_NUMBER")
}
stage('deploy') {
def containerName = 'hours-and-miles'
sh "docker stop ${containerName} || true"
sh "docker wait ${containerName} || true"
sh "docker rm -f ${containerName} || true"
def arguments = [
"--name ${containerName}",
'-e VIRTUAL_HOST=hours-and-miles.dev.timnederhoff.nl',
'-e LETSENCRYPT_HOST=hours-and-miles.dev.timnederhoff.nl',
'--expose 80',
'--restart=always'
].join(' ')
dockerImage.run(arguments)
}
}