Skip to content

Commit

Permalink
Merge pull request #114 from internetofwater/docker-network
Browse files Browse the repository at this point in the history
update network configuration in docker compose
  • Loading branch information
dblodgett-usgs authored May 1, 2024
2 parents ffd2fd4 + e72e110 commit 761d8ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
28 changes: 1 addition & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,6 @@ The `load-data.sh` script reads environment variables from a `.env` file accorin

To run the services with an at scale database, starting from a stand alone database from the this project can be accomplished with minor alterations to the docker-compose.yml to allow the two docker-compose projects to communicate on the same network.

Adding the following to docker-compse.yml allows connection to a pre-existing external docker network.
```
networks:
nldi:
external: true
```

Each service that needs to use that network then needs a `networks` element as in:

```
---
version: '3.3'
services:
nldi-services:
.
.
.
networks:
- nldi
```

With `networks` configured in docker-compose, the environment for the services need to match that of the database and things will connect. For the current (6/8/23) compose environment, that looks like the following.

NOTE: nldiDbHost is the name of the docker-compose service in the nldi-db project. nldidbUsername and Password need to be synced between the two projects.

```
environment:
serverContextPath: /nldi
Expand All @@ -119,7 +93,7 @@ NOTE: nldiDbHost is the name of the docker-compose service in the nldi-db projec
nldiHost: "localhost:8080"
nldiPath: /nldi
springFrameworkLogLevel: debug
nldiDbHost: db
nldiDbHost: localhost
nldiDbPort: 5432
nldiDbUsername: nldi_data
nldiDbPassword: changeMe
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
- NLDI_READ_ONLY_USERNAME=${NLDI_READ_ONLY_USERNAME}
- NLDI_READ_ONLY_PASSWORD=${NLDI_READ_ONLY_PASSWORD}
- NLDI_DATABASE_ADDRESS=${NLDI_DATABASE_ADDRESS}
network_mode: "host"
ports:
- ${DB_CI_PORT}:5432
container_name: nldi-db-ci
Expand All @@ -48,6 +49,7 @@ services:
- NLDI_READ_ONLY_USERNAME=${NLDI_READ_ONLY_USERNAME}
- NLDI_READ_ONLY_PASSWORD=${NLDI_READ_ONLY_PASSWORD}
- NLDI_DATABASE_ADDRESS=${NLDI_DATABASE_ADDRESS}
network_mode: "host"
ports:
- ${DB_DEMO_PORT}:5432
container_name: nldi-db-demo
Expand All @@ -57,6 +59,7 @@ services:
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${NLDI_DATABASE_NAME}
network_mode: "host"
ports:
- ${DB_PORT}:5432
container_name: nldi-db
Expand Down

0 comments on commit 761d8ae

Please sign in to comment.