From: Jean Privat Date: Wed, 20 Feb 2019 13:45:19 +0000 (-0500) Subject: ci: propose a docker-compose to handle services tests locally X-Git-Url: http://nitlanguage.org ci: propose a docker-compose to handle services tests locally Signed-off-by: Jean Privat --- diff --git a/misc/docker/ci-local/README.md b/misc/docker/ci-local/README.md new file mode 100644 index 0000000..4ac947a --- /dev/null +++ b/misc/docker/ci-local/README.md @@ -0,0 +1,34 @@ +# Local setup of services for tests + +Some tests and libs require specific external services like postgres. +To simplify the automation and the setup, we just assume these services are accessible at specific hostnames. + +When running and testing nit within a docker, it is easy to compose/link nit with other dockers/services. +See also .gitlab-ci.yml + +~~~ +$ docker run --link postgres [...] +~~~ + +When running and testing on a local host, one can setup those services locally then add aliases for localhost in `/etc/hosts`. + +~~~ +$ cat /etc/hosts +[...] +127.0.0.1 postgres +~~~ + +An other way is to run/test on a local host and have the services running in dockers. + +Because accessing a specific container by its name is cumbersome, a proposed way is to: + +* run these services with specific and fixed IPs +* add these IPs to `/etc/hosts` + +~~~ +$ cd misc/docker/ci-local +$ docker-compose up -d +$ cat /etc/hosts +[...] +172.16.238.4 postgres +~~~ diff --git a/misc/docker/ci-local/docker-compose.yml b/misc/docker/ci-local/docker-compose.yml new file mode 100644 index 0000000..aabc9f7 --- /dev/null +++ b/misc/docker/ci-local/docker-compose.yml @@ -0,0 +1,29 @@ +version: '2' +services: + mongo: + image: mongo + restart: always + networks: + nitci: + ipv4_address: 172.16.238.2 + neo4j: + image: neo4j:2.3 + restart: always + environment: + NEO4J_AUTH: none + networks: + nitci: + ipv4_address: 172.16.238.3 + postgres: + image: postgres + restart: always + networks: + nitci: + ipv4_address: 172.16.238.4 +networks: + nitci: + driver: bridge + ipam: + driver: default + config: + - subnet: 172.16.238.0/24