Docker Community Forums

Share and learn in the Docker community.

Run tests inside Docker container with Jenkins


(Maheshwaram Priyanka) #1

We want to give it a try to setup CI/CD with Jenkins for our project. The project itself has Elasticsearch and PostgreSQL as runtime dependencies and Webdriver for acceptance testing. In dev environment, everything is set up within one docker-compose.yml file and we have script to run acceptance tests.

After digging documentation I found that it’s potentially possible to build CI with following steps:

dockerize project
pull project from git repo
somehow pull docker-compose.yml and project Dockerfile - either:
put it in the project repo
put it in separate repo (this is how it’s done now)
put somewhere on a server and jut copy it over
execute docker-compose up
project’s Dockerfile will have ONBUILT section to run tests. Unit tests are run through mix tests and acceptance through scripts/ It’ll be cool to run them in parallel.
shutdown docker-compose, clean up containers
Because this is my first experience with Jenkins a series of questions arise:

Is this a viable strategy?
How to connect tests output with Jenkins?
How to run and shut down docker-compose?
Do we need/want to write a pipeline for that? Will we need/want pipeline when we will get to the CD on the next stage?

(Think) #2

if you use docker-compose and jenkins, be sure, that you do not use image-Tag. Build all Docker-Images fresh from the source. You want that your project is tested in the exact same revision as it is in the repository and not some arbitrary version from within a docker-compose file.

I also think it’s important to have a difference between production and development/testing environment. So I think it’s a failure to add your testing environment to your Images. It keeps your images larger as needed and adds complexity and attacking vectors.

(Nareshkonda043) #3

Thank You for Sharing this Useful Information with us.

(Anpphp) #4

Have you got it working?