From 5216ea44269c36ecc1821b40bd70f45ccf470dde Mon Sep 17 00:00:00 2001 From: skywalker Date: Mon, 26 Aug 2024 21:22:27 +0300 Subject: [PATCH] fix(dev): update docker compose --- tools/docker/docker-compose.yml | 22 +++++++++++----------- tools/docker/env/dev.env | 4 ++-- tools/docker/env/local.env | 2 +- tools/scripts/deploy.sh | 12 ++++++------ tools/scripts/runLocal.sh | 32 +++++++++++++++++++++++++++----- tools/scripts/stop.sh | 3 +-- 6 files changed, 48 insertions(+), 27 deletions(-) diff --git a/tools/docker/docker-compose.yml b/tools/docker/docker-compose.yml index 1ec4b9df..95560749 100644 --- a/tools/docker/docker-compose.yml +++ b/tools/docker/docker-compose.yml @@ -29,7 +29,7 @@ services: # platforms: # - "linux/amd64" # - "linux/arm64" - container_name: muse-server + container_name: "${MUSE_SERVER_IMAGE:-muse-server}" ports: - ${SERVER_PORT}:8080 - ${SERVER_DEBUG_PORT}:5005 @@ -45,16 +45,16 @@ services: postgres: condition: service_healthy - muse-client: - image: "${MUSE_CLIENT_IMAGE:-muse-client}" -# platforms: -# - "linux/amd64" -# - "linux/arm64" - container_name: muse-client - ports: - - ${CLIENT_PORT}:80 - networks: - - muse +# muse-client: +# image: "${MUSE_CLIENT_IMAGE:-muse-client}" +## platforms: +## - "linux/amd64" +## - "linux/arm64" +# container_name: "${MUSE_CLIENT_IMAGE:-muse-client}" +# ports: +# - ${CLIENT_PORT}:80 +# networks: +# - muse # muse-client-dev: # image: "${MUSE_CLIENT_DEV_IMAGE:-muse-client-dev}" diff --git a/tools/docker/env/dev.env b/tools/docker/env/dev.env index c3307726..ba4838ef 100644 --- a/tools/docker/env/dev.env +++ b/tools/docker/env/dev.env @@ -1,8 +1,8 @@ -SERVER_PORT=50505 +SERVER_PORT=10001 SERVER_DEBUG_PORT=50504 CLIENT_PORT=50001 -CLIENT_DEV_PORT=3001 +CLIENT_DEV_PORT=3003 POSTGRES_PORT=5555 POSTGRES_USER=muse diff --git a/tools/docker/env/local.env b/tools/docker/env/local.env index ab3ac6a3..f69c1580 100644 --- a/tools/docker/env/local.env +++ b/tools/docker/env/local.env @@ -1,4 +1,4 @@ -SERVER_PORT=8080 +SERVER_PORT=9000 SERVER_DEBUG_PORT=5005 CLIENT_PORT=3000 diff --git a/tools/scripts/deploy.sh b/tools/scripts/deploy.sh index f846e639..cc27e326 100755 --- a/tools/scripts/deploy.sh +++ b/tools/scripts/deploy.sh @@ -23,20 +23,20 @@ if [ -z "$SSH_PASS" ]; then exit 1 fi -dockerRepository=$1 +stage=$1 if [ -z "$1" ] then - echo -e "\033[0;33mNo Docker Hub username provided. 'myshx' will be used.\033[0m" - dockerRepository="myshx" + echo -e "\033[0;33mNo stage provided. 'DEV' stage will be used.\033[0m" + stage="dev" fi -stage=$2 +dockerRepository=$2 if [ -z "$2" ] then - echo -e "\033[0;33mNo stage provided. 'DEV' stage will be used.\033[0m" - stage="dev" + echo -e "\033[0;33mNo Docker Hub username provided. 'myshx' will be used.\033[0m" + dockerRepository="myshx" fi dockerTag="$stage-$(git rev-parse --short HEAD)" diff --git a/tools/scripts/runLocal.sh b/tools/scripts/runLocal.sh index d51c76a4..9acb87b6 100755 --- a/tools/scripts/runLocal.sh +++ b/tools/scripts/runLocal.sh @@ -3,10 +3,32 @@ set -e currentDir=$(cd -P -- "$(dirname -- "$0")" && pwd -P) rootDir="$currentDir/../../" -(cd "$rootDir" && exec ./tools/scripts/stop.sh) -(cd "$rootDir" && exec ./tools/scripts/clean.sh) -(cd "$rootDir" && exec ./tools/scripts/buildAndPush.sh) -(cd "$rootDir" && exec ./tools/scripts/run.sh) +stage=$1 + +dockerTag="latest" +if [ -z "$1" ] + then + echo -e "\033[0;33mNo stage provided. 'local' stage will be used.\033[0m" + stage="local" + dockerTag="$stage-$(git rev-parse --short HEAD)" +fi + +dockerRepository=$2 + +if [ -z "$2" ] + then + echo -e "\033[0;33mNo Docker Hub username provided. 'myshx' will be used.\033[0m" + dockerRepository="myshx" +fi + +(cd "$rootDir" && exec ./tools/scripts/stop.sh "$stage") +(cd "$rootDir" && exec ./tools/scripts/clean.sh "$stage") +(cd "$rootDir" && exec ./tools/scripts/buildAndPush.sh "$dockerRepository" "$dockerTag") + +MUSE_SERVER_IMAGE="$dockerRepository/muse-server:$dockerTag" +MUSE_CLIENT_IMAGE="$dockerRepository/muse-client:$dockerTag" +MUSE_CLIENT_DEV_IMAGE="$dockerRepository/muse-client-dev:$dockerTag" +(cd "$rootDir" && exec ./tools/scripts/run.sh "$stage") echo -e "\033[0;32mList of available ports:\n\033[0m" -(cd "$rootDir" && exec cat ./tools/docker/env/local.env) +(cd "$rootDir" && exec cat ./tools/docker/env/$stage.env) diff --git a/tools/scripts/stop.sh b/tools/scripts/stop.sh index 4cd9900c..dbe3be3d 100755 --- a/tools/scripts/stop.sh +++ b/tools/scripts/stop.sh @@ -11,11 +11,10 @@ if [ -z "$1" ] stage="local" fi - (cd "$rootDir" && exec docker compose \ -f ./tools/docker/docker-compose.yml \ --env-file ./tools/docker/env/$stage.env \ --project-name=muse-$stage \ - rm -f) + down -v) echo -e "\033[0;32mDocker Service has been stopped.\033[0m"