forked from AlexanderWyss/discord-bot-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
41 lines (41 loc) · 1.96 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
node {
def dockerImage
stage('Clone repository') {
checkout scm
}
stage('Dependencies Server') {
sh 'npm ci --unsafe-perm'
}
stage('Build Server') {
sh 'npm run build'
}
stage('Dependencies Client') {
dir('client') {
sh 'npm ci'
}
}
stage('Build Client') {
dir('client') {
sh 'npm run build:prod'
}
}
stage('Build image') {
dockerImage = docker.build("alexanderwyss/discord-bot-node", "-f DockerfileJenkins .")
}
stage('Push image') {
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
dockerImage.push(BUILD_NUMBER)
dockerImage.push("latest")
}
}
stage('Deploy') {
sh 'docker stop discord-bot-node || true && docker rm -f discord-bot-node || true'
withCredentials([string(credentialsId: 'Discord_Token', variable: 'token'), string(credentialsId: 'Discord_Owner', variable: 'owner')]) {
sh 'docker run -d --expose 8080 --restart unless-stopped --name discord-bot-node -e NODE_ENV=production -e PORT=8080 -e TOKEN=$token -e OWNER=$owner -e URL=https://discord.wyss.tech -e PREFIX=? -e VIRTUAL_HOST=discord.wyss.tech -e VIRTUAL_PORT=8080 -e LETSENCRYPT_HOST=discord.wyss.tech alexanderwyss/discord-bot-node:latest'
}
sh 'docker stop discord-bot-node-demo || true && docker rm -f discord-bot-node-demo || true'
withCredentials([string(credentialsId: 'Discord_Token_Demo', variable: 'token'), string(credentialsId: 'Discord_Owner', variable: 'owner')]) {
sh 'docker run -d --expose 8080 --restart unless-stopped --name discord-bot-node-demo -e NODE_ENV=production -e PORT=8080 -e TOKEN=$token -e OWNER=$owner -e URL=https://discord-demo.wyss.tech -e PREFIX=! -e VIRTUAL_HOST=discord-demo.wyss.tech -e VIRTUAL_PORT=8080 -e LETSENCRYPT_HOST=discord-demo.wyss.tech alexanderwyss/discord-bot-node:latest'
}
}
}