I am using Jenkins pipeline and run a shell command to bring up my linked containers for testing. Once the testing is complete, I want to push the containers to a registry (I would prefer AWS ERC, but at this point I will take any working examples). What is the proper way to do this? Should each image go to a different repository? How can I get all of the containers created by the compose file pushed up? I have been attempting to get this done with the docker-compose push command, but I can't seem to get it working properly or find any decent examples.
Jenkinsfile
node('ec2-build-slave') {
stage('Docker Build') {
/* This builds the actual image; synonymous to
* docker build on the command line */
sh("docker network create aa_backend_network")
sh("docker-compose up -d --build")
//docker.build("$IMAGE")
}
stage ('Docker Push'){
// /* This pushes the previously built image to the Amazon
// * ECS Container Registry */
sh("eval \$(aws ecr get-login --region us-west-2 --no-include-email | sed 's|https://||')")
// docker.withRegistry(ECR_URL, ECR_CRED) {
// docker.image(IMAGE).push()
// }
sh("docker-compose build")
sh("docker-compose push")
}
}
catch (exc) {
currentBuild.result = "FAILED"
throw exc
}
finally {
// Success or failure, always send notifications
notifyBuild(currentBuild.result)
sh("docker-compose down -v")
sh("docker network prune -f")
}
}
}
docker-compose
version: "2"
services:
db_setup:
networks:
- default
build: .
depends_on:
- db
container_name: db_setup
image: db_setup
command: python asteri_analytics_db.py
working_dir: /asteri_analytics_db/asteri_analytics_db
db:
networks:
- default
- outside
image: mongo:3.6.3
container_name: mongo_db
restart: always
environment:
MONGO_DATA_DIR: /data/db
MONGO_LOG_DIR: /dev/null
MONGO_INITDB_ROOT_USERNAME: ###edited####
MONGO_INITDB_ROOT_PASSWORD: ###edited####
ports:
- 27017:27017
networks:
outside:
external:
name: aa_backend_network