Saturday, November 7, 2020

Continuous Integration with Jenkins and Docker

Source:

(...) 

Here is what our Jenkinsfile looks like:

node('docker') {
stage 'Checkout'
checkout scm
stage 'Build & UnitTest'
sh "docker build -t accountownerapp:B${BUILD_NUMBER} -f Dockerfile ."
sh "docker build -t accountownerapp:test-B${BUILD_NUMBER} -f Dockerfile.Integration ."
stage 'Integration Test'
sh "docker-compose -f docker-compose.integration.yml up --force-recreate --abort-on-container-exit"
sh "docker-compose -f docker-compose.integration.yml down -v"
}

(...) 

docker-compose.integration.yml file:

version: '3.1'
services:
db:
(...) 
integration:
depends_on:
- accountownerapp
image: "accountownerapp:test-B${BUILD_NUMBER}"
build:
context: .
dockerfile: Dockerfile.Integration
environment:
(...)

No comments: