diff --git a/Jenkinsfile b/Jenkinsfile index 5c86650..21e12e8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,6 +7,7 @@ pipeline { BACKEND_IMAGE = "chore-app-frontend:${env.BUILD_ID}" VUE_CONTAINER_NAME = "chore-app-frontend" FLASK_CONTAINER_NAME = "chore-app-backend" + NETWORK_NAME = "chore-app-net" } stages { @@ -35,8 +36,11 @@ pipeline { stage('Deploy') { 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) // The || true prevents the build from failing if the container doesn't exist yet sh "docker stop ${VUE_CONTAINER_NAME} || true" @@ -51,7 +55,7 @@ pipeline { sh """ docker run -d \\ --name ${VUE_CONTAINER_NAME} \\ - --network chore-app-net \\ + --network ${NETWORK_NAME}" \\ -p 443:443 \\ ${FRONTEND_IMAGE} """ @@ -59,7 +63,7 @@ pipeline { sh """ docker run -d \\ --name ${FLASK_CONTAINER_NAME} \\ - --network chore-app-net \\ + --network ${NETWORK_NAME}" \\ ${BACKEND_IMAGE} """