-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsfile
59 lines (45 loc) · 1.9 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
pipeline {
agent any
stages {
stage('Checkout') {
steps {
echo 'Check out the code'
checkout([$class: 'GitSCM', branches: [[name: '*/main']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/IMRANDIL/Next_JS_Turbo_Repo_Scaleable_chat_APP.git']]])
}
}
stage('build') {
steps {
echo 'installing node_modules'
bat '''
cd apps/web/
npm install
npm run build
'''
echo 'done code building...'
}
}
stage('docker-build') {
steps {
echo 'Building images'
bat 'docker build -t imrandil/web-app-next -f apps/web/Dockerfile apps/web/'
echo 'Done Building image'
}
}
stage('image-publish') {
steps {
echo 'Publishing images to docker hub'
echo 'Logging to docker hub...'
// Log in to Docker Hub
withCredentials([usernamePassword(credentialsId: 'imrandil-pass', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
// Log in to Docker Hub
bat "docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD"
// Tag the local Docker image with the Docker Hub repository
bat 'docker tag imrandil/web-app-next imrandil/web-app-next:latest'
// Push the Docker image to Docker Hub
bat 'docker push imrandil/web-app-next:latest'
}
echo 'Done publishing image'
}
}
}
}