Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jhryniuk
Copy link
Contributor

No description provided.

Copy link
Contributor

@partikus partikus left a 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 to buildImages.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
Copy link
Contributor

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

Copy link
Contributor Author

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)"
Copy link
Contributor

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 ?

Copy link
Contributor Author

@jhryniuk jhryniuk Apr 22, 2017

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")
Copy link
Contributor

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}"
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@jhryniuk jhryniuk force-pushed the feature/split-bash branch from 23dbd58 to 9158b54 Compare April 24, 2017 07:37
bash/runBuild.sh Outdated
DIR=$1
export IMAGE_VERSION=$2

cd "${DIR}"
Copy link
Contributor

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'
Copy link
Contributor

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

@jhryniuk
Copy link
Contributor Author

@partikus @dominikpgs ping

@partikus
Copy link
Contributor

partikus commented May 1, 2017

@jhryniuk rebase please

@jhryniuk jhryniuk force-pushed the feature/split-bash branch from 7482730 to fb51702 Compare May 2, 2017 08:29
@partikus
Copy link
Contributor

Is it still relevant? Is it necessary to split docker.sh into few smaller one?
I think refactoring of docker.sh script is necessary but I have no ideas what we could improve.

Let's discuss.

@jhryniuk
Copy link
Contributor Author

jhryniuk commented Jul 20, 2017

I think that we can divide this file on basic sections.
Form example:

  • file with configuration of variables,
  • script with basic functions,
  • main script which use functions from script with functions and variables from configuration file.

It is just proposition.
I admit that I'd divide this scrip on to many files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants