Skip to content

Commit

Permalink
final updates and fixes to env vars and docker compose local development
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Valacco committed May 18, 2024
1 parent 3d42912 commit b539eff
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Each component in the `/services` directory has its own `docker-compose.yml` fil
Run the script to start all services:

```bash
sh run.sh
sh docker-run.sh
```

## Contributing
Expand Down
10 changes: 6 additions & 4 deletions run.sh → docker-run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

# Create Docker network
docker network create dataherald_network

docker-compose -p dataherald -f services/engine/docker-compose.yml up --build -d;
docker-compose -p dataherald -f services/enterprise/docker-compose.yml up --build -d;
docker-compose -p dataherald -f services/slackbot/docker-compose.yml up --build -d;
docker-compose -p dataherald -f services/admin-console/docker-compose.yml up --build -d;
# Bring up services with Docker Compose
docker-compose -p dataherald -f services/engine/docker-compose.yml up --build -d
docker-compose -p dataherald -f services/enterprise/docker-compose.yml up --build -d
docker-compose -p dataherald -f services/slackbot/docker-compose.yml up --build -d
docker-compose -p dataherald -f services/admin-console/docker-compose.yml up --build -d
4 changes: 4 additions & 0 deletions services/admin-console/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ COPY . .
# Uncomment the following line to disable telemetry at run time
ENV NEXT_TELEMETRY_DISABLED 1

# Docker network URL for the API -- used for nextjs server side API calls inside the docker network
# The browser needs to access the API from the exposed port in the docker host (i.e.: localhost:3001)
ENV DOCKER_API_URL='http://api:3001'

# Note: Don't expose ports here, Compose will handle that for us

# Start Next.js in development mode based on the preferred package manager
Expand Down
4 changes: 2 additions & 2 deletions services/admin-console/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
next-app:
container_name: next-app
container_name: console
build:
context: .
dockerfile: dev.Dockerfile
Expand All @@ -9,9 +9,9 @@ services:
volumes:
- ./src:/app/src
- ./public:/app/public
restart: always
ports:
- 3000:3000
restart: always
networks:
- dataherald_network
networks:
Expand Down
3 changes: 2 additions & 1 deletion services/admin-console/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const API_URL = process.env.NEXT_PUBLIC_API_URL
const isServer = typeof window === 'undefined';
export const API_URL = isServer ? process.env.DOCKER_API_URL || process.env.NEXT_PUBLIC_API_URL : process.env.NEXT_PUBLIC_API_URL;
export const AUTH = {
hostname: process.env.AUTH0_BASE_URL,
cliendId: process.env.AUTH0_CLIENT_ID,
Expand Down
2 changes: 1 addition & 1 deletion services/engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ It should look like this:
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
72aa8df0d589 dataherald-app "uvicorn dataherald.…" 7 seconds ago Up 6 seconds 0.0.0.0:80->80/tcp dataherald-app-1
6595d145b0d7 mongo:latest "docker-entrypoint.s…" 19 hours ago Up 6 seconds 0.0.0.0:27017->27017/tcp dataherald-mongodb-1
6595d145b0d7 mongo:latest "docker-entrypoint.s…" 19 hours ago Up 6 seconds 0.0.0.0:27017->27017/tcp mongodb
```

6. In your browser visit [http://localhost/docs](http://localhost/docs)
Expand Down
2 changes: 2 additions & 0 deletions services/engine/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
engine:
container_name: engine
build:
context: .
dockerfile: Dockerfile
Expand All @@ -18,6 +19,7 @@ services:
- dataherald_network
env_file: .env
mongodb:
container_name: mongodb
image: mongo:latest
restart: always
ports:
Expand Down
2 changes: 1 addition & 1 deletion services/engine/docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Starting Docker
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
72aa8df0d589 dataherald-app "uvicorn dataherald.…" 7 seconds ago Up 6 seconds 0.0.0.0:80->80/tcp dataherald-app-1
6595d145b0d7 mongo:latest "docker-entrypoint.s…" 19 hours ago Up 6 seconds 0.0.0.0:27017->27017/tcp dataherald-mongodb-1
6595d145b0d7 mongo:latest "docker-entrypoint.s…" 19 hours ago Up 6 seconds 0.0.0.0:27017->27017/tcp mongodb
#. You can also verify the engine is running by navigating to the Swagger-UI from your browser at `<http://localhost/docs>`_
Expand Down
4 changes: 2 additions & 2 deletions services/enterprise/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ENGINE_URL=http://{DOCKER_CONTAINER_APP_NAME:PORT}/api/v1 # example: http://dataherald-engine-1/api/v1 (port 80 by default)
ENGINE_URL=http://{DOCKER_CONTAINER_NAME:PORT}/api/v1 # example: http://engine/api/v1 (port 80 by default)
MONGODB_DB_NAME=
MONGODB_URI=

Expand All @@ -9,7 +9,7 @@ AUTH0_DISABED=False

API_KEY_SALT=

DEFAULT_K2_TIMEOUT=120
DEFAULT_ENGINE_TIMEOUT=120

S3_AWS_ACCESS_KEY_ID=
S3_AWS_SECRET_ACCESS_KEY=
Expand Down
2 changes: 1 addition & 1 deletion services/enterprise/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Settings(BaseSettings):
load_dotenv()

engine_url: str = os.environ.get("ENGINE_URL")
default_engine_timeout: int = os.environ.get("DEFAULT_K2_TIMEOUT")
default_engine_timeout: int = os.environ.get("DEFAULT_ENGINE_TIMEOUT")
encrypt_key: str = os.environ.get("ENCRYPT_KEY")
api_key_salt: str = os.environ.get("API_KEY_SALT")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
changeLogFile=changelog.json

#### Enter the Target database 'url' information ####
liquibase.command.url= mongodb://dataherald-mongodb-1:27017/dataherald
liquibase.command.url= mongodb://mongodb:27017/dataherald

# Enter the username for your Target database.
liquibase.command.username: admin
Expand Down
1 change: 1 addition & 0 deletions services/enterprise/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
api:
container_name: api
build:
context: .
dockerfile: Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion services/slackbot/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ AUTH0_CLIENT_ID='{yourClientId}'
AUTH0_CLIENT_SECRET='{yourClientSecret}'


API_URL=http://{DOCKER_CONTAINER_APP_NAME:PORT}/api/v1 # example: http://dataherald-api-1:3001
API_URL=http://{DOCKER_CONTAINER_NAME:PORT} # example: http://api:3001
PORT=3000
26 changes: 13 additions & 13 deletions services/slackbot/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
services:
slackbot:
build: .
working_dir: /app
ports:
- "3005:3005"
volumes:
- .:/app
- /app/node_modules
networks:
- dataherald_network
slackbot:
container_name: slackbot
build: .
working_dir: /app
ports:
- '3005:3005'
volumes:
- .:/app
- /app/node_modules
networks:
- dataherald_network
networks:
dataherald_network:
external: true

dataherald_network:
external: true

0 comments on commit b539eff

Please sign in to comment.