-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split generation and execution of docker commands
- Loading branch information
Showing
3 changed files
with
71 additions
and
54 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
# deploy components manually using the existing configuration for MSU | ||
|
||
env_files=$ENV_FILES | ||
|
||
outfile="service_config/deploy_components.sh" | ||
echo "" > $outfile | ||
|
||
file=$1 | ||
if [ -z $file ]; then | ||
echo "missing path to service config file (JSON)" | ||
exit 0 | ||
fi | ||
service_cnt=$(($(jq < $file | jq .services | jq length) - 1)) | ||
|
||
cnt=0 | ||
while [ $cnt -le $service_cnt ]; | ||
do | ||
# collect data from service config | ||
image=$(jq < $file | jq .services.[$cnt].image -r) | ||
tag=$(jq < $file | jq .services.[$cnt].tag -r) | ||
port_mapping=$(jq < $file | jq .services.[$cnt].port -r) | ||
env_file=$(jq < $file | jq '.services.['$cnt'].files.".env"' -r) | ||
container_name=${image/'/'/'-'} | ||
|
||
volumes=$(jq < $file | jq .services.[$cnt].volumes -r) | ||
if [ ! -z "${volumes}" ];then | ||
volume_mappings="" | ||
volume_cnt=$(($(echo $volumes | jq length) - 1)) | ||
i=0 | ||
while [ $i -le $volume_cnt ]; | ||
do | ||
mapping=$(echo $volumes | jq .[$i] -r) | ||
volume_mappings="$volume_mappings-v $mapping " | ||
i=$(($i + 1)) | ||
done | ||
fi | ||
|
||
echo 'echo "Stopping and removing old container"' >> $outfile | ||
echo 'docker stop $container_name || true && docker rm $container_name || true' >> $outfile | ||
echo 'echo "Pulling image: $DOCKER_IMAGE_NAME' >> $outfile | ||
echo 'docker pull "$image:$tag"' >> $outfile | ||
echo 'echo "Starting container: $DOCKER_CONTAINER_NAME"' >> $outfile | ||
|
||
if [ ! -z "${volume_mappings}" ];then | ||
echo 'echo "docker run --restart=always -d -p $port_mapping $volume_mappings --env-file $env_files/$env_file --name $container_name $image:$tag" ' >> $outfile | ||
echo '#docker run --restart=always -d -p $port_mapping $volume_mappings --env-file $env_files/$env_file --name $container_name "$image:$tag" ' >> $outfile | ||
else | ||
echo 'echo "docker run --restart=always -d -p $port_mapping --env-file $env_files/$env_file --name $container_name $image:$tag" ' >> $outfile | ||
echo '#docker run --restart=always -d -p $port_mapping --env-file $env_files/$env_file --name $container_name "$image:$tag" ' >> $outfile | ||
fi | ||
|
||
cnt=$(($cnt + 1)) | ||
done |