Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: automate ballerine deployment #2871

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 210 additions & 28 deletions ballerine_install.sh
Original file line number Diff line number Diff line change
@@ -1,55 +1,237 @@
#!/usr/bin/env bash
#!/bin/bash

set -e

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

echo "Running as: $(id)"
# Function to display help message
show_help() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -h, --help Display this help message."
echo " -d, --domain vite_domain Vite Domain URL."
echo " -v, --verbose Enable verbose output."
echo ""
echo "Examples:"
echo " $0 --domain example.com"
echo " $0 -v"
}


check_http_https() {
local input=$1
echo "checking domain if suitable $input"
if [[ $input == *http://* && $input != *https://* ]]; then
echo "The string contains 'http' but not 'https'."
elif [[ $input == *https://* && $input != *http://* ]]; then
echo "The string contains 'https' but not 'http'."
elif [[ $input == *http://* && $input == *https://* ]]; then
echo "The string contains both 'http' and 'https'."
exit 1;
else
echo "The string contains neither 'http' nor 'https'."
exit 1;
fi
}

Comment on lines +21 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Eliminate code duplication in HTTP/HTTPS validation

The HTTP/HTTPS validation logic is duplicated between check_http_https and deploy_ballerine functions. This violates the DRY principle and makes maintenance harder.

Refactor to reuse the validation logic:

 check_http_https() {
     local input=$1
     echo "checking domain if suitable $input"
+    local protocol=""
     if [[ $input == *http://* && $input != *https://* ]]; then
         echo "The string contains 'http' but not 'https'."
+        protocol="http"
     elif [[ $input == *https://* && $input != *http://* ]]; then
         echo "The string contains 'https' but not 'http'."
+        protocol="https"
     elif [[ $input == *http://* && $input == *https://* ]]; then
         echo "The string contains both 'http' and 'https'."
         exit 1;
     else
         echo "The string contains neither 'http' nor 'https'."
         exit 1;
     fi
+    echo "$protocol"
 }

 deploy_ballerine() {
     local input=$1
-    echo "checking domain if suitable $input"
-    if [[ $input == *http://* && $input != *https://* ]]; then
+    local protocol
+    protocol=$(check_http_https "$input")
+    if [[ "$protocol" == "http" ]]; then
       if [[ "$OSTYPE" == "darwin"* ]]; then
         cd deploy; sudo docker-compose -f docker-compose-build.yml up -d
       else
          cd deploy; sudo docker compose -f docker-compose-build.yml up -d
       fi
-    elif [[ $input == *https://* && $input != *http://* ]]; then
+    elif [[ "$protocol" == "https" ]]; then
        if [[ "$OSTYPE" == "darwin"* ]]; then
         cd deploy; sudo docker-compose -f docker-compose-build-https.yml up -d
        else
         cd deploy; sudo docker compose -f docker-compose-build-https.yml up -d
        fi
-    elif [[ $input == *http://* && $input == *https://* ]]; then
-        echo "The string contains both 'http' and 'https'."
-        exit 1;
     else
-        echo "The string contains neither 'http' nor 'https'."
         cd deploy; sudo docker-compose -f docker-compose-build.yml up -d
     fi
 }

Also applies to: 37-59

deploy_ballerine() {
local input=$1
echo "checking domain if suitable $input"
if [[ $input == *http://* && $input != *https://* ]]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
cd deploy; sudo docker-compose -f docker-compose-build.yml up -d
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add safety checks for directory operations

The cd commands lack error handling and directory existence verification, which could lead to script failures.

-      cd deploy; sudo docker-compose -f docker-compose-build.yml up -d
+      if [ ! -d "deploy" ]; then
+          echo "Error: deploy directory not found"
+          exit 1
+      fi
+      cd deploy || exit 1
+      sudo docker-compose -f docker-compose-build.yml up -d

Also applies to: 44-44, 48-48, 50-50, 57-57

cd deploy; sudo docker compose -f docker-compose-build.yml up -d
fi
elif [[ $input == *https://* && $input != *http://* ]]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
cd deploy; sudo docker-compose -f docker-compose-build-https.yml up -d
else
cd deploy; sudo docker compose -f docker-compose-build-https.yml up -d
fi
elif [[ $input == *http://* && $input == *https://* ]]; then
echo "The string contains both 'http' and 'https'."
exit 1;
else
echo "The string contains neither 'http' nor 'https'."
cd deploy; sudo docker-compose -f docker-compose-build.yml up -d
fi
}

# Check if no arguments are provided
if [ $# -eq 0 ]; then
echo "No arguments provided. Defaulting everything to localhost."
fi


install_docker_ubuntu(){
echo "Installing docker..."
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
}


install_docker_macos(){
echo "Install docker using the following docs"
echo "https://docs.docker.com/desktop/setup/install/mac-install/"
}


WORKFLOW_SERVICE_DOMAIN_NAME=$1
check_os() {
# Get the operating system name
uname_out="$(uname -s)"

function update_frontend_build_variables() {
case "${uname_out}" in
Linux*)
# Check if the Linux distro is Ubuntu
if [ -f /etc/os-release ]; then
. /etc/os-release
if [[ $ID == "ubuntu" ]]; then
echo "The host is running Ubuntu."
install_docker_ubuntu
else
echo "The host is running a Linux distribution but not Ubuntu."
echo "We do not support this Linux distribution"
exit 1
fi
else
echo "The host is running Linux but /etc/os-release is not available."
fi
;;
Darwin*)
echo "The host is running macOS."
install_docker_macos
;;
*)
echo "The operating system is not recognized."
exit 1
;;
esac
}

Comment on lines +92 to +122
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Verify Docker installation success

The script should verify that Docker was successfully installed and is running.

 check_os() {
+    verify_docker() {
+        if ! command -v docker >/dev/null 2>&1; then
+            echo "Error: Docker installation failed"
+            exit 1
+        fi
+        if ! docker info >/dev/null 2>&1; then
+            echo "Error: Docker daemon is not running"
+            exit 1
+        fi
+    }
+
     # Get the operating system name
     uname_out="$(uname -s)"
     case "${uname_out}" in
         Linux*)
             if [ -f /etc/os-release ]; then
                 . /etc/os-release
                 if [[ $ID == "ubuntu" ]]; then
                     echo "The host is running Ubuntu."
                     install_docker_ubuntu
+                    verify_docker
                 else
                     echo "The host is running a Linux distribution but not Ubuntu."
                     echo "We do not support this Linux distribution"
                     exit 1
                 fi
             else
                 echo "The host is running Linux but /etc/os-release is not available."
             fi
             ;;
         Darwin*)
             echo "The host is running macOS."
             install_docker_macos
+            verify_docker
             ;;
         *)
             echo "The operating system is not recognized."
             exit 1
             ;;
     esac
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
check_os() {
# Get the operating system name
uname_out="$(uname -s)"
function update_frontend_build_variables() {
case "${uname_out}" in
Linux*)
# Check if the Linux distro is Ubuntu
if [ -f /etc/os-release ]; then
. /etc/os-release
if [[ $ID == "ubuntu" ]]; then
echo "The host is running Ubuntu."
install_docker_ubuntu
else
echo "The host is running a Linux distribution but not Ubuntu."
echo "We do not support this Linux distribution"
exit 1
fi
else
echo "The host is running Linux but /etc/os-release is not available."
fi
;;
Darwin*)
echo "The host is running macOS."
install_docker_macos
;;
*)
echo "The operating system is not recognized."
exit 1
;;
esac
}
check_os() {
verify_docker() {
if ! command -v docker >/dev/null 2>&1; then
echo "Error: Docker installation failed"
exit 1
fi
if ! docker info >/dev/null 2>&1; then
echo "Error: Docker daemon is not running"
exit 1
fi
}
# Get the operating system name
uname_out="$(uname -s)"
case "${uname_out}" in
Linux*)
if [ -f /etc/os-release ]; then
. /etc/os-release
if [[ $ID == "ubuntu" ]]; then
echo "The host is running Ubuntu."
install_docker_ubuntu
verify_docker
else
echo "The host is running a Linux distribution but not Ubuntu."
echo "We do not support this Linux distribution"
exit 1
fi
else
echo "The host is running Linux but /etc/os-release is not available."
fi
;;
Darwin*)
echo "The host is running macOS."
install_docker_macos
verify_docker
;;
*)
echo "The operating system is not recognized."
exit 1
;;
esac
}


update_frontend_build_variables() {
echo "Updating env variables for frontend apps..."
VITE_DOMAIN_NAME="$1"
## Get frontend application env files
echo "Updating frontend Build Variables"
echo "Updating vite domain with $VITE_DOMAIN_NAME"
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
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s|http://localhost:3000|$VITE_DOMAIN_NAME|g" $i
else
sed -i "s|http://localhost:3000|$VITE_DOMAIN_NAME|g" $i
fi
done
Comment on lines 132 to +140
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add error handling for file operations

The find commands lack error handling, and the script continues even if no files are found.

-    env_files=$(find ./apps -name "*.env.example")
-    echo $env_files
+    env_files=$(find ./apps -name "*.env.example") || {
+        echo "Error: Failed to search for env files"
+        exit 1
+    }
+    if [ -z "$env_files" ]; then
+        echo "Warning: No .env.example files found"
+        return
+    }
+    echo "Found env files: $env_files"

Also applies to: 156-168


}

function update_env_docker_compose(){
## update env variables for docker-compose yaml

update_docker_compose(){
echo "Updating Docker Compose..."
WORKFLOW_SERVICE_DOMAIN=$1
read -p "Enter the backoffice domain: " BACKOFFICE_DOMAIN
check_http_https $BACKOFFICE_DOMAIN
read -p "Enter the workflow dashboard domain: " WORKFLOW_DASHBOARD_DOMAIN
check_http_https $WORKFLOW_DASHBOARD_DOMAIN
read -p "Enter the kyb domain: " KYB_DOMAIN
check_http_https $KYB_DOMAIN
create_caddy_file $BACKOFFICE_DOMAIN $WORKFLOW_DASHBOARD_DOMAIN $KYB_DOMAIN $WORKFLOW_SERVICE_DOMAIN
echo "Updating docker-compose env variables"
env_files=$(find ./deploy -name "*.env")
env_files=$(find ./deploy -name "docker-compose-build*")
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;
echo "Updating env variables for KYB in $i"
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s|http://localhost:3000|$VITE_DOMAIN_NAME|g" $i
sed -i '' "s|http://localhost:5201|$KYB_DOMAIN|g" $i
sed -i '' "s|http://localhost:5200|$WORKFLOW_DASHBOARD_DOMAIN|g" $i
else
sed -i "s|http://localhost:3000|$VITE_DOMAIN_NAME|g" $i
sed -i "s|http://localhost:5201|$KYB_DOMAIN|g" $i
sed -i "s|http://localhost:5200|$WORKFLOW_DASHBOARD_DOMAIN|g" $i
fi
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

create_caddy_file(){
echo "Creating Caddy file..."
BACKOFFICE_DOMAIN=$1
WORKFLOW_DASHBOARD_DOMAIN=$2
KYB_DOMAIN=$3
WORKFLOW_SERVICE_DOMAIN=$4
mkdir -p "$PWD/deploy/caddy"
output_file="$PWD/deploy/caddy/Caddyfile"
cat <<EOF > "$output_file"
$BACKOFFICE_DOMAIN {
reverse_proxy backoffice:80
}

$WORKFLOW_SERVICE_DOMAIN {
reverse_proxy workflow-service:3000
}

$KYB_DOMAIN {
reverse_proxy kyb-app:80
}

install_docker
$WORKFLOW_DASHBOARD_DOMAIN {
reverse_proxy workflows-dashboard:80
}
EOF

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
}


# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
show_help
exit 0
;;
-d|--domain)
if [ -n "$2" ]; then
VITE_DOMAIN_NAME="$2"
echo "VITE DOMAIN: $VITE_DOMAIN_NAME"
check_http_https $VITE_DOMAIN_NAME
update_frontend_build_variables $VITE_DOMAIN_NAME
update_docker_compose $VITE_DOMAIN_NAME
shift 2
else
echo "Error: --domain requires a domain name."
exit 1
fi
;;
-v|--verbose)
VERBOSE=true
echo "Verbose mode enabled."
shift
;;
*)
echo "Unknown option: $1"
echo "Use -h or --help for usage information."
exit 1
;;
esac
done

Comment on lines +202 to +233
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Address unused VERBOSE flag and improve argument validation

The VERBOSE flag is set but never used, and domain validation should happen before assignment.

+# Logging function
+log_verbose() {
+    if [ "${VERBOSE:-false}" = true ]; then
+        echo "[DEBUG] $*"
+    fi
+}
+
 while [[ $# -gt 0 ]]; do
     case "$1" in
         -d|--domain)
             if [ -n "$2" ]; then
+                # Validate domain before assignment
+                if ! validate_domain_url "$2"; then
+                    exit 1
+                fi
                 VITE_DOMAIN_NAME="$2"
-                echo "VITE DOMAIN: $VITE_DOMAIN_NAME"
-                check_http_https $VITE_DOMAIN_NAME
+                log_verbose "VITE DOMAIN: $VITE_DOMAIN_NAME"
                 update_frontend_build_variables $VITE_DOMAIN_NAME
                 update_docker_compose $VITE_DOMAIN_NAME
                 shift 2

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 208-208: VERBOSE appears unused. Verify use (or export if used externally).

(SC2034)

check_os

## Bring docker-container up
cd deploy; sudo docker-compose -f docker-compose-build.yml up -d
deploy_ballerine $VITE_DOMAIN_NAME
13 changes: 8 additions & 5 deletions deploy/docker-compose-build-https.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ services:
- ballerine-workflow-service
restart: on-failure
environment:
VITE_API_URL: 'http://${DOMAIN_NAME:-localhost:3000}/api/v1/'
VITE_API_URL: 'http://localhost:3000/api/v1/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid hardcoding localhost URLs in Docker configurations

Hardcoding localhost:3000 reduces deployment flexibility. Consider keeping the parameterized version using environment variables to support different deployment environments.

-      VITE_API_URL: 'http://localhost:3000/api/v1/'
+      VITE_API_URL: 'http://${DOMAIN_NAME:-localhost:3000}/api/v1/'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
VITE_API_URL: 'http://localhost:3000/api/v1/'
VITE_API_URL: 'http://${DOMAIN_NAME:-localhost:3000}/api/v1/'

VITE_KYB_DEFINITION_ID: 'kyb_parent_kyc_session_example'
ballerine-workflow-service:
container_name: workflow-service
platform: linux/amd64
image: ghcr.io/ballerine-io/workflows-service:latest
build:
context: ../services/workflows-service/
command:
- /bin/sh
- -c
Expand All @@ -49,10 +50,10 @@ services:
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
SESSION_SECRET: ${SESSION_SECRET}
BACKOFFICE_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${BACKOFFICE_PORT}
WORKFLOW_DASHBOARD_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${WORKFLOW_DASHBOARD_PORT}
BACKOFFICE_CORS_ORIGIN: http://localhost:5137
WORKFLOW_DASHBOARD_CORS_ORIGIN: http://localhost:5200
PORT: ${WORKFLOW_SVC_PORT}
KYB_EXAMPLE_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${KYB_APP_PORT}
KYB_EXAMPLE_CORS_ORIGIN: http://localhost:5201
Comment on lines +53 to +56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Revise CORS configuration for security and flexibility

  1. Hardcoding CORS origins to localhost limits deployment flexibility
  2. Consider security implications of CORS configuration in production
-      BACKOFFICE_CORS_ORIGIN: http://localhost:5137
-      WORKFLOW_DASHBOARD_CORS_ORIGIN: http://localhost:5200
-      KYB_EXAMPLE_CORS_ORIGIN: http://localhost:5201
+      BACKOFFICE_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${BACKOFFICE_PORT:-5137}
+      WORKFLOW_DASHBOARD_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${WORKFLOW_DASHBOARD_PORT:-5200}
+      KYB_EXAMPLE_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${KYB_APP_PORT:-5201}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
BACKOFFICE_CORS_ORIGIN: http://localhost:5137
WORKFLOW_DASHBOARD_CORS_ORIGIN: http://localhost:5200
PORT: ${WORKFLOW_SVC_PORT}
KYB_EXAMPLE_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${KYB_APP_PORT}
KYB_EXAMPLE_CORS_ORIGIN: http://localhost:5201
BACKOFFICE_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${BACKOFFICE_PORT:-5137}
WORKFLOW_DASHBOARD_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${WORKFLOW_DASHBOARD_PORT:-5200}
PORT: ${WORKFLOW_SVC_PORT}
KYB_EXAMPLE_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${KYB_APP_PORT:-5201}

APP_API_URL: https://alon.ballerine.dev
EMAIL_API_TOKEN: ''
EMAIL_API_URL: https://api.sendgrid.com/v3/mail/send
Expand Down Expand Up @@ -97,6 +98,7 @@ services:
timeout: 45s
interval: 10s
retries: 10
restart: on-failure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix duplicate restart policy in caddy service

The caddy service has conflicting restart policies:

  1. restart: unless-stopped (line 103)
  2. restart: on-failure (line 114)

Remove the duplicate restart policy and decide on a single strategy:

  caddy:
    image: caddy:latest
    restart: unless-stopped
    container_name: caddy
    ports:
      - 80:80
      - 443:443
    volumes:
      - "../deploy/caddy/Caddyfile:/etc/caddy/Caddyfile"
      - "../deploy/./caddy/site:/srv"
      - "../deploy/caddy/caddy_data:/data"
      - "../deploy/caddy/caddy_config:/config"
-    restart: on-failure

Also applies to: 114-114

caddy:
image: caddy:latest
restart: unless-stopped
Expand All @@ -109,5 +111,6 @@ services:
- "../deploy/./caddy/site:/srv"
- "../deploy/caddy/caddy_data:/data"
- "../deploy/caddy/caddy_config:/config"
restart: on-failure
volumes:
postgres15: ~
9 changes: 5 additions & 4 deletions deploy/docker-compose-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
- ballerine-workflow-service
restart: on-failure
environment:
VITE_API_URL: 'http://${DOMAIN_NAME:-localhost:3000}/api/v1/'
VITE_API_URL: 'http://localhost:3000/api/v1/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Hardcoding VITE_API_URL to localhost may limit flexibility.

Setting VITE_API_URL to 'http://localhost:3000/api/v1/' restricts the application to only work with a local API server. In production environments, the API might be hosted on a different domain. Consider making this URL configurable.

Apply this diff to restore configurability:

 VITE_API_URL: 'http://localhost:3000/api/v1/'
+# Consider using an environment variable or a Docker argument to set VITE_API_URL dynamically.

Committable suggestion skipped: line range outside the PR's diff.

VITE_KYB_DEFINITION_ID: 'kyb_parent_kyc_session_example'
ballerine-workflow-service:
container_name: workflow-service
Expand All @@ -50,10 +50,10 @@ services:
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
SESSION_SECRET: ${SESSION_SECRET}
BACKOFFICE_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${BACKOFFICE_PORT}
WORKFLOW_DASHBOARD_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${WORKFLOW_DASHBOARD_PORT}
BACKOFFICE_CORS_ORIGIN: http://localhost:5137
WORKFLOW_DASHBOARD_CORS_ORIGIN: http://localhost:5200
PORT: ${WORKFLOW_SVC_PORT}
KYB_EXAMPLE_CORS_ORIGIN: http://${DOMAIN_NAME:-localhost}:${KYB_APP_PORT}
KYB_EXAMPLE_CORS_ORIGIN: http://localhost:5201
Comment on lines +53 to +56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Hardcoding CORS origins may cause cross-origin issues.

By hardcoding the CORS origins to localhost, services running on other domains won't be able to communicate with the API. This can cause issues in staging or production environments.

Apply this diff to make the CORS origins configurable:

 BACKOFFICE_CORS_ORIGIN: http://localhost:5137
 WORKFLOW_DASHBOARD_CORS_ORIGIN: http://localhost:5200
 KYB_EXAMPLE_CORS_ORIGIN: http://localhost:5201
+# Consider using environment variables to set these origins dynamically based on deployment.

Committable suggestion skipped: line range outside the PR's diff.

APP_API_URL: https://alon.ballerine.dev
EMAIL_API_TOKEN: ''
EMAIL_API_URL: https://api.sendgrid.com/v3/mail/send
Expand Down Expand Up @@ -98,5 +98,6 @@ services:
timeout: 45s
interval: 10s
retries: 10
restart: on-failure
volumes:
postgres15: ~
Loading