-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
62 lines (56 loc) · 1.62 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
pipeline {
agent any
stages {
stage('Clone Repository') {
steps {
// Checkout the source code from the Git repository
script {
git 'https://github.com/raton1180/pwa.git'
}
}
}
stage('Build and Install Dependencies') {
steps {
// Use Node.js container for building and installing dependencies
script {
docker.image('node:14').inside('-v $PWD:/app') {
sh 'cd /app && npm install'
}
}
}
}
stage('Build React Project') {
steps {
// Use Node.js container for building the React project
script {
docker.image('node:14').inside('-v $PWD:/app') {
sh 'cd /app && npm run build'
}
}
}
}
stage('Docker Build and Run') {
steps {
// Build Docker image and run the React app
script {
docker.build('react-app', '.')
docker.run('-p 3000:3000 --name react-container react-app')
}
}
}
stage('Cleanup') {
steps {
// Remove Docker container
script {
docker.image('react-app').remove()
}
}
}
}
post {
always {
// Clean up Docker images and containers
cleanWs()
}
}
}