ci: propose a docker-compose to handle services tests locally
authorJean Privat <jean@pryen.org>
Wed, 20 Feb 2019 13:45:19 +0000 (08:45 -0500)
committerJean Privat <jean@pryen.org>
Thu, 21 Feb 2019 16:22:20 +0000 (11:22 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

misc/docker/ci-local/README.md [new file with mode: 0644]
misc/docker/ci-local/docker-compose.yml [new file with mode: 0644]

diff --git a/misc/docker/ci-local/README.md b/misc/docker/ci-local/README.md
new file mode 100644 (file)
index 0000000..4ac947a
--- /dev/null
@@ -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 (file)
index 0000000..aabc9f7
--- /dev/null
@@ -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