From 44fe149ed893369e8ce5351baa0f5db06516a944 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Tue, 16 Nov 2021 05:29:55 +0500 Subject: [PATCH] chore: docker start script for development --- dockerStartDev.sh | 29 ++++++++++++++++++++++++ startProduction.sh => dockerStartProd.sh | 12 +++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100755 dockerStartDev.sh rename startProduction.sh => dockerStartProd.sh (54%) diff --git a/dockerStartDev.sh b/dockerStartDev.sh new file mode 100755 index 0000000..774dd3f --- /dev/null +++ b/dockerStartDev.sh @@ -0,0 +1,29 @@ +sasjsPath=$(grep sasPath ./api/package.json | sed 's/.*"sasPath": "\(.*\)".*/\1/') + +if [ -z "$sasjsPath" ] +then + echo "Please enter path to SAS executable:" + read sasjsPath + +fi + +if [ -e $sasjsPath ] +then + echo "Using sas executable:" \"$sasjsPath\" +else + echo "No file present at:" \"$sasjsPath\" + exit 1 +fi + +# copy sas executable to current directory, because docker cannot copy files outside of context. +cp $sasjsPath ./ + +# name of the sas executable file, placed at root of repository +sasjs=$(basename $sasjsPath) +echo "SAS Executable name:" $sasjs + +# build and run docker-compose +SAS_EXEC=$sasjs docker-compose up --build -d + +# remove copied sas executable +rm $sasjs \ No newline at end of file diff --git a/startProduction.sh b/dockerStartProd.sh similarity index 54% rename from startProduction.sh rename to dockerStartProd.sh index bb7848f..5deb6d5 100755 --- a/startProduction.sh +++ b/dockerStartProd.sh @@ -1,4 +1,4 @@ -sasjsPath=$(grep sasPath package.json | sed 's/.*"sasPath": "\(.*\)".*/\1/') +sasjsPath=$(grep sasPath ./api/package.json | sed 's/.*"sasPath": "\(.*\)".*/\1/') if [ -z "$sasjsPath" ] then @@ -15,9 +15,15 @@ else exit 1 fi +# copy sas executable to current directory, because docker cannot copy files outside of context. cp $sasjsPath ./ -sasjs=$(basename $sasjsPath) +# name of the sas executable file, placed at root of repository +sasjs=$(basename $sasjsPath) echo "SAS Executable name:" $sasjs -SAS_EXEC=$sasjs docker-compose -f docker-compose.prod.yml up --build -d \ No newline at end of file +# build and run docker-compose +SAS_EXEC=$sasjs docker-compose -f docker-compose.prod.yml up --build -d + +# remove copied sas executable +rm $sasjs \ No newline at end of file