Skip to content

Commit

Permalink
Update install files
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelmello committed Dec 15, 2022
1 parent 7d2cd1f commit 22e886d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 30 deletions.
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,11 @@ Pre-requisites:

- Install [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/).

Replace the environment variable values and run the following snippet:
Download the installation script and run it with bash.

```sh
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/comnetunb/dispatcher-master/master/install.sh | sh
```

Or, you can execute the script contents yourself.

```sh
mkdir -p /tmp/dispatcher-master
cd /tmp/dispatcher-master

curl -L https://raw.githubusercontent.com/comnetunb/dispatcher-master/master/docker-compose.prod.yml -o docker-compose.yml

echo "Auth Secret Key is used for user authentication, please use a secure value."
read -s -p "Auth Secret Key:" AUTH_SECRET_KEY

export DISPATCHER_MASTER_PORT=8080

sudo docker-compose up -d
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/comnetunb/dispatcher-master/master/install.sh > /tmp/install-dispatcher.sh
bash /tmp/install-dispatcher.sh
```

## Development
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ services:
- DB_HOST=dispatcher-mongodb
- DB_DATA=ons
- DB_PORT=27017
- WEB_API_PORT=8080
- WORKER_API_PORT=16180
- AUTH_SECRET_KEY=${AUTH_SECRET_KEY}
- WEB_API_PORT=${DISPATCHER_MASTER_WEB_API_PORT}
- WORKER_API_PORT=${DISPATCHER_MASTER_WORKER_API_PORT}
- AUTH_SECRET_KEY=${DISPATCHER_MASTER_SECRET_KEY}
ports:
- ${DISPATCHER_MASTER_PORT}:8080
- 16180:16180
- ${DISPATCHER_MASTER_WEB_API_PORT}:${DISPATCHER_MASTER_WEB_API_PORT}
- ${DISPATCHER_MASTER_WORKER_API_PORT}:${DISPATCHER_MASTER_WORKER_API_PORT}
depends_on:
- dispatcher-mongodb
dispatcher-mongodb:
Expand Down
51 changes: 44 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
#!/bin/bash
set -e -u -o pipefail
#!/bin/sh
set -e
set -a

DEFAULT_WEB_API_PORT=8080
DEFAULT_WORKER_API_PORT=16180

echo -e "Settings for the dispatcher:\n"

echo -e "Auth Secret Key is a key used to sign JWTs that serve the purpose of authenticating user sessions."
echo -e "Please write a secure key below that will be used for this instance of the Dispatcher."
read -s -p "Auth Secret Key: " AUTH_SECRET_KEY

echo -e "\n\nPort used to listen for incoming connections for the web server, accessible to users."
read -p "Web server port ($DEFAULT_WEB_API_PORT): " WEB_API_PORT
if [ "$WEB_API_PORT" = "" ]; then
WEB_API_PORT=$DEFAULT_WEB_API_PORT
fi

echo -e "\n\nPort used to listen for incoming connections for the worker API server, used by workers to communicate with the main server."
read -p "Worker API port ($DEFAULT_WORKER_API_PORT): " WORKER_API_PORT
if [ "$WORKER_API_PORT" = "" ]; then
WORKER_API_PORT=$DEFAULT_WORKER_API_PORT
fi

echo -e "\nStarting installation..."
echo -e " - Creating temporary dir /tmp/dispatcher-master"
mkdir -p /tmp/dispatcher-master
cd /tmp/dispatcher-master

curl -L https://raw.githubusercontent.com/comnetunb/dispatcher-master/master/docker-compose.prod.yml -o docker-compose.yml
echo -e " - Downloading docker-compose definition from the GitHub repository"
curl --fail -L https://raw.githubusercontent.com/comnetunb/dispatcher-master/master/docker-compose.prod.yml >docker-compose.yml

echo -e " - Starting containers..."
sudo \
DISPATCHER_MASTER_SECRET_KEY=$AUTH_SECRET_KEY \
DISPATCHER_MASTER_WEB_API_PORT=$WEB_API_PORT \
DISPATCHER_MASTER_WORKER_API_PORT=$WORKER_API_PORT \
docker-compose up -d

echo -e "\n\n"

echo "Auth Secret Key is used for user authentication, please use a secure value."
read -s -p "Auth Secret Key:" AUTH_SECRET_KEY
echo -e "Dispatcher is installed and running on port $WEB_API_PORT of this machine!\n"

export DISPATCHER_MASTER_PORT=8080
echo -e "The database is stored inside a docker volume called 'mongodb_data_container', how that works can be read here: https://docs.docker.com/storage/volumes/\n"

sudo docker-compose up -d
read -p "Do you want to tail the logs? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo docker logs dispatcher-master -f
fi

0 comments on commit 22e886d

Please sign in to comment.