63 lines
1.7 KiB
Groovy
63 lines
1.7 KiB
Groovy
pipeline {
|
|
agent any
|
|
|
|
environment {
|
|
DOCKER_IMAGE_NODE = 'your-node-image:latest'
|
|
DOCKER_IMAGE_DJANGO = 'your-django-image:latest'
|
|
DOCKER_IMAGE_POSTGRES = 'postgres:latest'
|
|
DOCKER_COMPOSE_FILE = 'docker-compose.yml'
|
|
}
|
|
|
|
stages {
|
|
stage('Checkout') {
|
|
steps {
|
|
// Checkout the code from Gitea
|
|
git url: 'http://your-gitea-instance/your-repo.git', branch: 'main'
|
|
}
|
|
}
|
|
|
|
stage('Build Node.js') {
|
|
steps {
|
|
script {
|
|
// Build Node.js application
|
|
sh 'docker build -t ${DOCKER_IMAGE_NODE} ./node-app'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Build Django') {
|
|
steps {
|
|
script {
|
|
// Build Django application
|
|
sh 'docker build -t ${DOCKER_IMAGE_DJANGO} ./django-app'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Run Tests') {
|
|
steps {
|
|
script {
|
|
// Run tests using Docker Compose
|
|
sh "docker-compose -f ${DOCKER_COMPOSE_FILE} up --abort-on-container-exit"
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Deploy') {
|
|
steps {
|
|
script {
|
|
// Deploy using Docker Compose
|
|
sh "docker-compose -f ${DOCKER_COMPOSE_FILE} up -d"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
always {
|
|
// Clean up Docker containers and images
|
|
sh 'docker-compose -f ${DOCKER_COMPOSE_FILE} down'
|
|
sh "docker rmi ${DOCKER_IMAGE_NODE} ${DOCKER_IMAGE_DJANGO} || true"
|
|
}
|
|
}
|
|
} |