Created
March 22, 2016 04:28
-
-
Save negabaro/e2e49d2a5bb7f914dca2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env_check() { | |
if [ -n "$SLAVE_DB_NAME" ] && \ | |
[ -n "$SLAVE_DB_USER" ] && \ | |
[ -n "$SLAVE_DB_PASSWORD" ] && \ | |
[ -n "$SLAVE_DB_HOST" ] && \ | |
[ -n "$DB_NAME" ] && \ | |
[ -n "$DB_USER" ] && \ | |
[ -n "$DB_PASSWORD" ] && \ | |
[ -n "$DB_HOST" ] && \ | |
[ -n "$RAILS_ENV" ]; | |
then | |
echo "env we need is alright" | |
return 1; | |
else | |
return 0; | |
fi | |
} | |
build() { | |
docker build \ | |
--build-arg SLAVE_DB_NAME=$SLAVE_DB_NAME \ | |
--build-arg SLAVE_DB_USER=$SLAVE_DB_USER \ | |
--build-arg SLAVE_DB_PASSWORD=$SLAVE_DB_PASSWORD \ | |
--build-arg SLAVE_DB_HOST=$SLAVE_DB_HOST \ | |
--build-arg DB_NAME=$DB_NAME \ | |
--build-arg DB_USER=$DB_USER \ | |
--build-arg DB_PASSWORD=$DB_PASSWORD \ | |
--build-arg DB_HOST=$DB_HOST \ | |
-t filmarks_beta_img_$RAILS_ENV . | |
} | |
rm_file_list() { | |
rm -rf Dockerfile | |
rm -rf restart_docker*.sh | |
rm -rf EnvSetting.sh | |
} | |
copy_file_list() { | |
cp -rp docker/$RAILS_ENV/Dockerfile_$RAILS_ENV ./Dockerfile | |
cp -rp docker/$RAILS_ENV/EnvSetting_"$RAILS_ENV".sh ./EnvSetting.sh | |
cp -rp docker/$RAILS_ENV/restart_docker.sh ./restart_docker.sh | |
} | |
env_check | |
if [ $? -eq 1 ]; then | |
if [ "$RAILS_ENV" = "test" ]; then | |
echo "===============test================" | |
#docker build -t fapi_img . | |
elif [ "$RAILS_ENV" = "development" ]; then | |
echo "================development==================" | |
rm_file_list | |
copy_file_list | |
build | |
elif [ "$RAILS_ENV" = "staging" ]; then | |
echo "================staging==================" | |
rm_file_list | |
copy_file_list | |
build | |
elif [ "$RAILS_ENV" = "production" ]; then | |
echo "================production==================" | |
rm_file_list | |
copy_file_list | |
build | |
else | |
echo "'$RAILS_ENV'RAILS_ENV 環境変数が正しく定されているか確認お願いします。" | |
fi | |
else | |
echo "環境変数が設定されてませんので必須環境変数を設定してください。" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment