4 ms·
I do this: docker build -t $APPNAME:$timestamp . OUTPUT="$(docker service inspect -f '{{.Spec.Name}}' sv-$APPNAME || true)" if [ "$OUTPUT" == "" ];
by coding123 9y ago
I do this:
docker build -t $APPNAME:$timestamp .
OUTPUT="$(docker service inspect -f '{{.Spec.Name}}' sv-$APPNAME || true)"
if [ "$OUTPUT" == "" ]; then
# Service does not exist
echo "Creating service"
docker service create --update-delay 5s \
--publish $PUBPORT:8080 --replicas 2 \
--mount type=bind,source=$(cd ../images; pwd),target=/images,readonly=true \
--mount type=bind,source=$(cd ../processed_images; pwd),target=/app/images \
--mount type=bind,source=$(cd ..; pwd)/config.json,target=/config.json,readonly=true \
--mount type=bind,source=$(cd ~/.aws; pwd),target=/root/.aws,readonly=true \
--name sv-$APPNAME $APPNAME:$timestamp
else
# Service exists
echo "Updating service"
docker service update --image $APPNAME:$timestamp sv-$APPNAME
I haven't looked in a while, but it would be nice if they had some kind of "upstall" (update/install) kinda like upsert (update/insert) in CRUD land.