diff --git a/README.md b/README.md index f6caf2f3..6bd0e9f7 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/run.sh b/docker-run.sh similarity index 68% rename from run.sh rename to docker-run.sh index e6ff39ff..d7ee97b5 100644 --- a/run.sh +++ b/docker-run.sh @@ -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; \ No newline at end of file +# 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 \ No newline at end of file diff --git a/services/admin-console/dev.Dockerfile b/services/admin-console/dev.Dockerfile index 2cbffed0..9aed10d1 100644 --- a/services/admin-console/dev.Dockerfile +++ b/services/admin-console/dev.Dockerfile @@ -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 diff --git a/services/admin-console/docker-compose.yml b/services/admin-console/docker-compose.yml index 7a8a1909..95277ccb 100644 --- a/services/admin-console/docker-compose.yml +++ b/services/admin-console/docker-compose.yml @@ -1,6 +1,6 @@ services: next-app: - container_name: next-app + container_name: console build: context: . dockerfile: dev.Dockerfile @@ -9,9 +9,9 @@ services: volumes: - ./src:/app/src - ./public:/app/public - restart: always ports: - 3000:3000 + restart: always networks: - dataherald_network networks: diff --git a/services/admin-console/src/config.ts b/services/admin-console/src/config.ts index d36a41eb..6f368cd3 100644 --- a/services/admin-console/src/config.ts +++ b/services/admin-console/src/config.ts @@ -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, diff --git a/services/engine/README.md b/services/engine/README.md index 36edc18e..457d22f3 100644 --- a/services/engine/README.md +++ b/services/engine/README.md @@ -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) diff --git a/services/engine/docker-compose.yml b/services/engine/docker-compose.yml index b97181e1..20a71f27 100644 --- a/services/engine/docker-compose.yml +++ b/services/engine/docker-compose.yml @@ -1,5 +1,6 @@ services: engine: + container_name: engine build: context: . dockerfile: Dockerfile @@ -18,6 +19,7 @@ services: - dataherald_network env_file: .env mongodb: + container_name: mongodb image: mongo:latest restart: always ports: diff --git a/services/engine/docs/quickstart.rst b/services/engine/docs/quickstart.rst index e0698dba..33e1ac81 100644 --- a/services/engine/docs/quickstart.rst +++ b/services/engine/docs/quickstart.rst @@ -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 ``_ diff --git a/services/enterprise/.env.example b/services/enterprise/.env.example index bee144b8..11aca32e 100644 --- a/services/enterprise/.env.example +++ b/services/enterprise/.env.example @@ -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= @@ -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= diff --git a/services/enterprise/config.py b/services/enterprise/config.py index 03e53198..1836608e 100644 --- a/services/enterprise/config.py +++ b/services/enterprise/config.py @@ -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") diff --git a/services/enterprise/database/migrations/liquibase.properties b/services/enterprise/database/migrations/liquibase.properties index df880700..ca2e9ec5 100644 --- a/services/enterprise/database/migrations/liquibase.properties +++ b/services/enterprise/database/migrations/liquibase.properties @@ -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 diff --git a/services/enterprise/docker-compose.yml b/services/enterprise/docker-compose.yml index 1bbe8a1c..2a09737a 100644 --- a/services/enterprise/docker-compose.yml +++ b/services/enterprise/docker-compose.yml @@ -1,5 +1,6 @@ services: api: + container_name: api build: context: . dockerfile: Dockerfile diff --git a/services/slackbot/.env.example b/services/slackbot/.env.example index d320fede..c71c419d 100644 --- a/services/slackbot/.env.example +++ b/services/slackbot/.env.example @@ -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 \ No newline at end of file diff --git a/services/slackbot/docker-compose.yml b/services/slackbot/docker-compose.yml index 6bc2954f..2fd3bd03 100644 --- a/services/slackbot/docker-compose.yml +++ b/services/slackbot/docker-compose.yml @@ -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