Skip to content

Commit

Permalink
feat(app): startweb standalone on any docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mmabrouk committed Jul 18, 2024
1 parent f645c82 commit a6fc25f
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions start_web_standalone.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit a6fc25f

Please sign in to comment.