Right now our Jenkins agents generate a docker-compose.yml for each of our Rails projects and then run docker-compose up. The docker-compose.yml has a main \"web\" container
In case you might run more docker-compose services with same name on one docker engine, and you don't know the exact name:
docker-compose up -d
(exit "${$(docker-compose logs -f test-chrome)##* }")
echo %?
- returns exit code from test-chrome service
Benefits:
docker-rails allows you to specify which container's error code is returned to the main process, so you CI server can determine the result. It is a great solution for CI and development for rails with docker.
For example
exit_code: web
in your docker-rails.yml
will yield the web
containers exit code as a result of the command docker-rails ci test
. docker-rails.yml
is just a meta wrapper around the standard docker-compose.yml
that gives you the potential to inherit/reuse the same base config for different environments i.e. development vs test vs parallel_tests.
Use docker wait
to get the exit code:
$ docker-compose -p foo up -d
$ ret=$(docker wait foo_bar_1)
foo
is the "project name". In the example above, I specified it explicitly, but if you don't supply it, it's the directory name. bar
is the name you give to the system under test in your docker-compose.yml.
Note that docker logs -f
does the right thing, too, exiting when the container stops. So you can put
$ docker logs -f foo_bar_1
between the docker-compose up
and the docker wait
so you can watch your tests run.