Skip to content

Commit

Permalink
feat(ballerine_install.sh): add ballerine_install.sh script to automa… (
Browse files Browse the repository at this point in the history
#2122)

* feat: add ballerine_install.sh script for installing and configuring Ballerine

The `ballerine_install.sh` script is added to the repository. This script is used to install and configure Ballerine. It takes a domain name as an argument and performs the following tasks:

- Updates frontend build variables in the `.env.example` files of the `apps` directory, replacing the `localhost` with the provided domain name.
- Updates environment variables in the `.env` files of the `deploy` directory, replacing the `DOMAIN_NAME=""` with the provided domain name.
- Installs Docker and Docker Compose.
- If a domain name is provided, it updates the frontend build variables and environment variables.
- If a domain name is not provided, it displays a message to provide a domain name.

The `ballerine_install.sh` script can be executed with a domain name argument to install and configure Ballerine on a specific domain.

---

docs: update deploy/README.md

The `deploy/README.md` file is updated to reflect the changes made in the installation process. The instructions for running the `docker-compose.yml` file are modified to include running the `ballerine_install.sh` script with a domain name argument.

---

chore: remove deploy/scripts/boot.sh

The `deploy/scripts/boot.sh` script is removed from the repository as it is no longer needed. The functionality provided by this script is now handled by the `ballerine_install.sh` script.

* chore(ballerine_install.sh): add command to bring up docker container after updating build variables and environment configuration

* Update ballerine_install.sh

---------

Co-authored-by: Alon Peretz <[email protected]>
  • Loading branch information
pratapalakshmi and alonp99 authored Mar 5, 2024
1 parent 70be7c7 commit 04fd4d6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 103 deletions.
55 changes: 55 additions & 0 deletions ballerine_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

set -e

# Example Usage:
# ./ballerine_install.sh <VITE_API_URL_DOMAIN_NAME>

echo "Running as: $(id)"

WORKFLOW_SERVICE_DOMAIN_NAME=$1

function update_frontend_build_variables() {
## Get frontend application env files
echo "Updating frontend Build Variables"
env_files=$(find ./apps -name "*.env.example")
echo $env_files
for i in $env_files;
do
echo "Updating env variables of $i"
sed -i "s/localhost/${WORKFLOW_SERVICE_DOMAIN_NAME}/g" $i
done

}

function update_env_docker_compose(){
## update env variables for docker-compose yaml
echo "Updating docker-compose env variables"
env_files=$(find ./deploy -name "*.env")
for i in $env_files;
do
echo "Updating env variables of $i"
sed -i "s/DOMAIN_NAME=\"\"/DOMAIN_NAME=\"${WORKFLOW_SERVICE_DOMAIN_NAME}\"/g" $i;
done
}

function install_docker(){
sudo apt update;
sudo apt install -y docker.io
mkdir -p ~/.docker/cli-plugins/
curl -SL https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
sudo mv ~/.docker/cli-plugins/docker-compose /usr/bin/docker-compose
}


install_docker

if [[ ! -z "${WORKFLOW_SERVICE_DOMAIN_NAME}" ]]; then
### Update frontend build variables only if domain_name is given
update_frontend_build_variables
update_env_docker_compose
fi

## Bring docker-container up
cd deploy; sudo docker-compose -f docker-compose-build.yml up -d
43 changes: 5 additions & 38 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,52 +25,19 @@ To start using the `docker-compose.yml` file in a repository, you need to clone
4. Once the cloning process is complete, navigate to the cloned repository directory:

```shell
cd deploy
cd ballerine;
```

## Understanding the docker-compose.yml File

The `docker-compose.yml` file in the cloned repository defines the services and configurations required for the project. Take some time to understand the structure and content of the file. It typically contains service definitions, volumes, networks, and other configurations specific to the project.

## Running Containers with Docker Compose

To start the Docker services defined in the `docker-compose.yml` file, follow these steps:

1. Open a terminal or command prompt.
2. Navigate to the root directory of the cloned repository (where the `docker-compose.yml` file is located).
5. Run the ballerine_install script with domain name incase Ballerine is installed on any cloud provider

```shell
cd deploy
```

3. Update env file with all the required values

``` shell
BACKOFFICE_PORT=5137
HEADLESS_SVC_PORT=5173
WORKFLOW_SVC_PORT=3000
BCRYPT_SALT=10
API_KEY="secret"
NODE_ENV="development"
COMPOSE_PROJECT_NAME=ballerine-x
DB_PORT=5432
DB_USER=admin
DB_PASSWORD=admin
SESSION_SECRET=secret
SESSION_EXPIRATION_IN_MINUTES=60
BACKOFFICE_CORS_ORIGIN=
HEADLESS_EXAMPLE_CORS_ORIGIN=
WORKFLOW_DASHBOARD_CORS_ORIGIN=
WORKFLOW_DASHBOARD_PORT=5200
WEBSOCKET_SVC_PORT=3500
KYB_APP_PORT=5201
DOMAIN_NAME="<domain on which Ballerine should be up>"
./ballerine_install.sh <domain_name>
```

4. Bring up the containers
For Example:

```shell
docker-compose -f docker-compose-build.yml up -d
./ballerine_install.sh gpwf.eu-central-1.ballerine.io
```

## Additional Docker Compose Commands
Expand Down
7 changes: 2 additions & 5 deletions deploy/docker-compose-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ services:
VITE_KYB_DEFINITION_ID: 'kyb_parent_kyc_session_example'
ballerine-workflow-service:
container_name: workflow-service
build:
context: ../services/workflows-service/
args:
NPM_LOG_LEVEL: notice
image: ghcr.io/ballerine-io/workflows-service:latest
command:
- /bin/sh
- -c
- |
npm run db:init
npm run seed:ex
npm run seed
dumb-init npm run prod
ports:
- ${WORKFLOW_SVC_PORT}:${WORKFLOW_SVC_PORT}
Expand Down
60 changes: 0 additions & 60 deletions deploy/scripts/boot.sh

This file was deleted.

0 comments on commit 04fd4d6

Please sign in to comment.