added jenkins deployment
This commit is contained in:
10
Jenkinsfile
vendored
10
Jenkinsfile
vendored
@@ -7,6 +7,7 @@ pipeline {
|
|||||||
BACKEND_IMAGE = "chore-app-frontend:${env.BUILD_ID}"
|
BACKEND_IMAGE = "chore-app-frontend:${env.BUILD_ID}"
|
||||||
VUE_CONTAINER_NAME = "chore-app-frontend"
|
VUE_CONTAINER_NAME = "chore-app-frontend"
|
||||||
FLASK_CONTAINER_NAME = "chore-app-backend"
|
FLASK_CONTAINER_NAME = "chore-app-backend"
|
||||||
|
NETWORK_NAME = "chore-app-net"
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
@@ -35,8 +36,11 @@ pipeline {
|
|||||||
|
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
steps {
|
steps {
|
||||||
echo 'Stopping and removing old containers...'
|
echo 'Cleaning up and creating network...'
|
||||||
|
sh "docker network rm -f ${NETWORK_NAME} || true"
|
||||||
|
sh "docker network create ${NETWORK_NAME}"
|
||||||
|
|
||||||
|
echo 'Stopping and removing old containers...'
|
||||||
// 1. Stop and remove the old running containers (if they exist)
|
// 1. Stop and remove the old running containers (if they exist)
|
||||||
// The || true prevents the build from failing if the container doesn't exist yet
|
// The || true prevents the build from failing if the container doesn't exist yet
|
||||||
sh "docker stop ${VUE_CONTAINER_NAME} || true"
|
sh "docker stop ${VUE_CONTAINER_NAME} || true"
|
||||||
@@ -51,7 +55,7 @@ pipeline {
|
|||||||
sh """
|
sh """
|
||||||
docker run -d \\
|
docker run -d \\
|
||||||
--name ${VUE_CONTAINER_NAME} \\
|
--name ${VUE_CONTAINER_NAME} \\
|
||||||
--network chore-app-net \\
|
--network ${NETWORK_NAME}" \\
|
||||||
-p 443:443 \\
|
-p 443:443 \\
|
||||||
${FRONTEND_IMAGE}
|
${FRONTEND_IMAGE}
|
||||||
"""
|
"""
|
||||||
@@ -59,7 +63,7 @@ pipeline {
|
|||||||
sh """
|
sh """
|
||||||
docker run -d \\
|
docker run -d \\
|
||||||
--name ${FLASK_CONTAINER_NAME} \\
|
--name ${FLASK_CONTAINER_NAME} \\
|
||||||
--network chore-app-net \\
|
--network ${NETWORK_NAME}" \\
|
||||||
${BACKEND_IMAGE}
|
${BACKEND_IMAGE}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user