Skip to content

Commit

Permalink
Change the network mode from host to bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
sadiqkhoja committed Dec 13, 2024
1 parent 9696780 commit ac7d68a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ In addition to the Backend and the Frontend, Central deploys services:
* 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.
* 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).

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.
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:

* Set `DOMAIN=central-dev` in .env file.
* Add an entry in your `/etc/hosts` file for `127.0.0.1 central-dev`.
* Create `local.json` in central-backend directory and set value of default.env.domain to `http://central-dev:8989`

Operations
----------
Expand Down
15 changes: 8 additions & 7 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ services:
postgres14:
profiles:
- central
network_mode: host
ports:
- 5432:5432
postgres:
profiles:
- central
Expand All @@ -28,9 +29,8 @@ services:
pyxform:
profiles:
- central
# changing port here - can't use `ports` mapping with host networking
command: ["gunicorn", "--bind", "0.0.0.0:5001", "--workers", "5", "--timeout", "600", "--max-requests", "1", "--max-requests-jitter", "3", "main:app()"]
network_mode: host
ports:
- 5001:80
secrets:
profiles:
- central
Expand All @@ -48,14 +48,15 @@ services:
- enketo_redis_main
environment:
- ENV=DEV
network_mode: host
extra_hosts:
- "${DOMAIN}:host-gateway"
ports:
- 8005:8005
enketo_redis_main:
profiles:
- central
network_mode: host
enketo_redis_cache:
profiles:
- central
network_mode: host
volumes:
dev_secrets:
5 changes: 0 additions & 5 deletions files/enketo/start-enketo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
CONFIG_PATH=${ENKETO_SRC_DIR}/config/config.json
echo "generating enketo configuration..."

if [ "$ENV" = "DEV" ]; then
sed -i -e 's/enketo_redis_main/localhost/g' \
-e 's/enketo_redis_cache/localhost/g' "$CONFIG_PATH.template"
fi

BASE_URL=$( [ "${HTTPS_PORT}" = 443 ] && echo https://"${DOMAIN}" || echo https://"${DOMAIN}":"${HTTPS_PORT}" ) \
SECRET=$(cat /etc/secrets/enketo-secret) \
LESS_SECRET=$(cat /etc/secrets/enketo-less-secret) \
Expand Down

0 comments on commit ac7d68a

Please sign in to comment.