sh8s_deployer/docker.md

36 lines
776 B
Markdown
Raw Normal View History

docker_service="$(echo "$service" | tr '.' '_')"
## deploy
if $deploy ; then
section "Logging to registry"
# XXX Login to docker registry
section "Pulling images"
docker-compose pull
if [ "$?" -ne 0 ] ; then
echo "PULL FAILED"
fi
section "Starting service"
run docker-compose up -d --remove-orphans
[ "$?" -ne 0 ] && echo "Erreur docker compose" && returncode=1
else
section "Removing containers"
run docker-compose down --rmi all --remove-orphans
fi
fi
## clean
if ! "$deploy" ; then
section "Remove stray containers"
while read container ; do
[ -z "$container" ] && continue || true
echo "Removing $container"
run docker rm "$container"
done <<< "$(docker ps | grep "$docker_service" | cut -d ' ' -f 1)"
fi