Skip to content

Commit

Permalink
add script to run docker containers under the same network and project
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Valacco committed May 17, 2024
1 parent e0cf408 commit 2186641
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 17 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,26 @@ This repository contains four components under `/services` which can be used tog
1. Engine: The core natural language-to-SQL engine. If you would like to use the dataherald API without users or authentication, running the engine will suffice.
2. Enterprise: The application API layer which adds authentication, organizations and users, and other business logic to Dataherald.
3. Admin-console: The front-end component of Dataherald which allows a GUI for configuration and observability. You will need to run both engine and enterprise for the admin-console to work.
4. Slack: A slackbot which allows users from a slack channel to interact with dataherald. Requires both engine and enterprise to run.
4. Slackbot: A slackbot which allows users from a slack channel to interact with dataherald. Requires both engine and enterprise to run.

For more information on each component, please take a look at their `README.md` files.

## Running locally

Each component in the `/services` directory has its own `docker-compose.yml` file. To set up the environment, follow these steps:

1. **Set Environment Variables**:
Each service requires specific environment variables. Refer to the `.env.example` file in each service directory and create a `.env` file with the necessary values.
> For the Next.js front-end app is `.env.local`
2. **Run Services**:
You can run all the services using a single script located in the root directory. This script creates a common Docker network and runs each service in detached mode.

Run the script to start all services:

```bash
sh run.sh
```

## Contributing
As an open-source project in a rapidly developing field, we are open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.

Expand Down
8 changes: 8 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

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;
2 changes: 2 additions & 0 deletions services/admin-console/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM node:18-alpine

LABEL Author="Juan Sebastian Valacco"

WORKDIR /app

# Install dependencies based on the preferred package manager
Expand Down
5 changes: 5 additions & 0 deletions services/admin-console/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ services:
restart: always
ports:
- 3000:3000
networks:
- dataherald_network
networks:
dataherald_network:
external: true
2 changes: 2 additions & 0 deletions services/admin-console/prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM --platform=linux/amd64 node:18-alpine AS base

LABEL Author="Juan Sebastian Valacco"

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
Expand Down
2 changes: 1 addition & 1 deletion services/engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Fernet.generate_key()
>We need to set it up externally to enable external clients running on docker to communicate with this app.
Run the following command:
```
docker network create backendnetwork
docker network create dataherald_network
```

4. Build docker images, create containers and raise them. This will raise the app and mongo container
Expand Down
9 changes: 4 additions & 5 deletions services/engine/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: "3.9"
services:
app:
engine:
build:
context: .
dockerfile: Dockerfile
Expand All @@ -16,7 +15,7 @@ services:
depends_on:
- mongodb
networks:
- backendnetwork
- dataherald_network
env_file: .env
mongodb:
image: mongo:latest
Expand All @@ -32,7 +31,7 @@ services:
MONGO_INITDB_ROOT_PASSWORD: "${MONGODB_DB_PASSWORD}"
MONGO_INITDB_DATABASE: "${MONGODB_DB_NAME}"
networks:
- backendnetwork
- dataherald_network
networks:
backendnetwork:
dataherald_network:
external: true
2 changes: 1 addition & 1 deletion services/engine/docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Starting Docker

#. Create a Docker network for communication between services (the Dataherald engine and Mongo) using the following command

```docker network create backendnetwork```
```docker network create dataherald_network```


#. Build the docker images, create containers and raise them by running
Expand Down
4 changes: 2 additions & 2 deletions services/enterprise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ We use Docker to create the environment ai-server.
>We need to set it up externally to enable external clients running on docker to communicate with this app.
Run the following command:
```
docker network create backendnetwork
docker network create dataherald_network
```
>If you are running ai-engine locally on docker, you can find container's IP by running this command:
```
Expand Down Expand Up @@ -103,7 +103,7 @@ Follow these steps to set up and run the Enterprise and Engine containers for lo

1. Create the docker network if it doesn't exist
```
docker network create backendnetwork
docker network create dataherald_network
```

2. Set the envvars in the .env file for `server` and `dataherald` projects
Expand Down
7 changes: 3 additions & 4 deletions services/enterprise/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: "3.9"
services:
app:
api:
build:
context: .
dockerfile: Dockerfile
Expand All @@ -13,7 +12,7 @@ services:
volumes:
- .:/app
networks:
- backendnetwork
- dataherald_network
networks:
backendnetwork:
dataherald_network:
external: true
5 changes: 2 additions & 3 deletions services/slackbot/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
slackbot:
build: .
Expand All @@ -9,8 +8,8 @@ services:
- .:/app
- /app/node_modules
networks:
- backendnetwork
- dataherald_network
networks:
backendnetwork:
dataherald_network:
external: true

0 comments on commit 2186641

Please sign in to comment.