From a6fc25f94e6795ce1c679e61ffcbb5521c0cbd1e Mon Sep 17 00:00:00 2001 From: Mahmoud Mabrouk Date: Thu, 18 Jul 2024 16:31:20 +0200 Subject: [PATCH] feat(app): startweb standalone on any docker --- start_web_standalone.sh | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) mode change 100644 => 100755 start_web_standalone.sh diff --git a/start_web_standalone.sh b/start_web_standalone.sh old mode 100644 new mode 100755 index 77f43e6944..11955100fc --- a/start_web_standalone.sh +++ b/start_web_standalone.sh @@ -1,21 +1,18 @@ # Example:- -# for prod: ./start_web_standalone.sh prod or ./start_web_standalone.sh prod demo -# for dev: ./start_web_standalone.sh or ./start_web_standalone.sh dev demo +# ./start_web_standalone.sh docker-compose.yml +# ./start_web_standalone.sh docker-compose.demo.yml +# ./start_web_standalone.sh docker-compose.demo.prod.yml -env="dev" -suffix="" - -# set the env value if it is passed in as a cli argument -if [[ ! -z $1 ]]; then - env="$1" +# Check if a dockerfile is provided as an argument +if [[ -z $1 ]]; then + echo "Please provide a docker-compose file as an argument." + exit 1 fi -# set the suffix value based on variant and env value -if [[ ! -z $2 ]]; then - suffix="${2}.${env}." -elif [[ $env == "prod" ]]; then - suffix="${env}." -fi +compose_file="$1" + +# Extract the parts of the filename +IFS='.' read -r -a parts <<< "$compose_file" # install dependencies for agenta-web cd agenta-web @@ -24,21 +21,22 @@ if [ ! -d "node_modules" ]; then fi cd .. -echo "Running in ${env} mode" -compose_file="docker-compose.${suffix}yml" -echo "compose_file: $compose_file" +echo "Using docker-compose file: $compose_file" # run docker compose without agenta-web service export NEXT_PUBLIC_STANDALONE="true" docker compose -f $compose_file down docker compose -f $compose_file up -d --build --scale agenta-web=0 -if [[ $env == "prod" ]]; then +# Check if the last part is 'prod' +if [[ "${parts[@]: -1}" == "prod" ]]; then + echo "Running in production mode" # run next js app in prod mode cd agenta-web npm run build npm run start else + echo "Running in development mode" # run next js app in dev mode cd agenta-web npm run dev