Devided docker.sh script to smaller onse#23
Conversation
partikus
left a comment
There was a problem hiding this comment.
Multiple files approach looks nice but I noticed few improvements:
- each file should indicate intention of file commands e.g. from
build.shtobuildImages.sh - there is a lot of workarounds like
cd&&__DIRwhich are not clear - variables defined & used only under function block should have
localscope 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.
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.
Order is not important because those scripts contain only functions.
Calling those functions is below in this file, when everything is included.
| 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.
Why did you choose such naming convention __DIR ?
There was a problem hiding this comment.
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.
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.
is there better option to run below commands under __DIR?
There was a problem hiding this comment.
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.
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.
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.