-
Notifications
You must be signed in to change notification settings - Fork 6
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
Devided docker.sh script to smaller onse #23
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple files approach looks nice but I noticed few improvements:
- each file should indicate intention of file commands e.g. from
build.sh
tobuildImages.sh
- there is a lot of workarounds like
cd
&&__DIR
which are not clear - variables defined & used only under function block should have
local
scope see more - each file should apply SRP
I'm looking forward to improvements to merge it.
docker.sh
Outdated
docker-compose -f docker-compose.yml -f docker-compose.local.yml kill > /dev/null 2>&1 | ||
docker-compose -f docker-compose.yml -f docker-compose.local.yml rm -f -v > /dev/null 2>&1 | ||
} | ||
for FILE in $(ls "${__DIR}/bash") ; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you walk through the file lists you're not sure of order. this loop should be replaced by predefined list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order is not important because those scripts contain only functions.
Calling those functions is below in this file, when everything is included.
docker.sh
Outdated
echo "User ID: $USERID"; | ||
echo -e "\nIMAGE VERSION: $APP_NAME:$APP_VERSION\n"; | ||
declare -i BUILD_STATUS=0; | ||
__DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you choose such naming convention __DIR
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I treated location as a magic variable
It is good to set this variable as a unique among of all variables.
@dominikpgs @tarnawski @partikus what do you think about that?
bash/variable.sh
Outdated
@@ -0,0 +1,15 @@ | |||
#!/usr/bin/env bash | |||
|
|||
export PROJECT_NAME=$(cat "${__DIR}/.project_name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where __DIR
is defined? in another file but it could be confusing
bash/run.sh
Outdated
function runInBackground { | ||
export IMAGE_VERSION=$1 | ||
|
||
cd "${__DIR}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there better option to run below commands under __DIR
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes there is, but code will lose on readability.
23dbd58
to
9158b54
Compare
bash/runBuild.sh
Outdated
DIR=$1 | ||
export IMAGE_VERSION=$2 | ||
|
||
cd "${DIR}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can not we change directory globally in docker.sh
?
docker.sh
Outdated
'checkContainerExists.sh' | ||
'runBuild.sh' | ||
'runInBackground.sh' | ||
'setupVariable.sh' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to rename this file to defineVariables.sh
@partikus @dominikpgs ping |
@jhryniuk rebase please |
7482730
to
fb51702
Compare
Is it still relevant? Is it necessary to split Let's discuss. |
I think that we can divide this file on basic sections.
It is just proposition. |
No description provided.