Skip to content

Commit 26dc362

Browse files
authored
Add dev docker-compose file to manage supporting services (#525)
* Added a docker compose file for development * Added Makefile for quick start and stop * Added instruction in README.md
1 parent 477e4b0 commit 26dc362

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
docker-compose-dev := docker compose --profile central -f docker-compose.yml -f docker-compose.dev.yml
2+
3+
.PHONY: dev
4+
dev:
5+
$(docker-compose-dev) up -d
6+
7+
.PHONY: stop
8+
stop:
9+
$(docker-compose-dev) stop

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ In addition to the Backend and the Frontend, Central deploys services:
2828
* Central relies on [pyxform-http](https://github.com/getodk/pyxform-http) for converting Forms from XLSForm. It generally shouldn't be needed in development but can be run locally.
2929
* Central relies on [Enketo](https://github.com/enketo/enketo-express) for Web Form functionality. Enketo can be run locally and configured to work with Frontend and Backend in development by following [these instructions](https://github.com/getodk/central-frontend/blob/master/docs/enketo.md).
3030

31+
If you want to work on Central codebase and don't want to setup dependent services like Postgresql, Enketo, etc manually then you can run `make dev`, which will start those services as Docker containers. With this setup you would need a local domain name, `central-dev` is a good choice. Following are the places where you need to add this:
32+
33+
* Set `DOMAIN=central-dev` in .env file.
34+
* Add an entry in your `/etc/hosts` file for `127.0.0.1 central-dev`.
35+
* Create `local.json` in central-backend directory and set value of default.env.domain to `http://central-dev:8989`
36+
3137
Operations
3238
----------
3339

docker-compose.dev.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Assumption: This file will be merged by `docker compose`
2+
#
3+
# What it does:
4+
# Sets profiles for each service depending on whether that
5+
# service is required for Central development or not.
6+
#
7+
# depends_on of some services are reset using !reset custom yml tag
8+
# nb: can't replace depends_on so we have removed all the values, ok for dev
9+
services:
10+
postgres14:
11+
profiles:
12+
- central
13+
ports:
14+
- 5432:5432
15+
postgres:
16+
profiles:
17+
- central
18+
image: debian:bullseye
19+
command: /bin/sh -c 'mkdir -p /var/lib/postgresql/14/data && touch /var/lib/postgresql/14/.postgres14-upgrade-successful'
20+
mail:
21+
profiles:
22+
- none
23+
service:
24+
profiles:
25+
- none
26+
nginx:
27+
profiles:
28+
- none
29+
pyxform:
30+
profiles:
31+
- central
32+
ports:
33+
- 5001:80
34+
secrets:
35+
profiles:
36+
- central
37+
volumes:
38+
- dev_secrets:/etc/secrets
39+
working_dir: /etc/secrets
40+
command: /bin/sh -c 'echo "s0m3v3rys3cr3tk3y" > enketo-secret && echo "this $3cr3t key is crackable" > enketo-less-secret && echo "enketorules" > enketo-api-key'
41+
enketo:
42+
profiles:
43+
- central
44+
volumes:
45+
- dev_secrets:/etc/secrets
46+
depends_on: !override
47+
- secrets
48+
- enketo_redis_main
49+
environment:
50+
- ENV=DEV
51+
extra_hosts:
52+
- "${DOMAIN}:host-gateway"
53+
ports:
54+
- 8005:8005
55+
enketo_redis_main:
56+
profiles:
57+
- central
58+
enketo_redis_cache:
59+
profiles:
60+
- central
61+
volumes:
62+
dev_secrets:

0 commit comments

Comments
 (0)