diff --git a/dockerfiles/services/launch_apps.sh b/dockerfiles/services/launch_apps.sh index af223b4..95cbcd4 100644 --- a/dockerfiles/services/launch_apps.sh +++ b/dockerfiles/services/launch_apps.sh @@ -23,5 +23,7 @@ docker stack deploy --with-registry-auth --prune -c prometheus/docker-compose-pr sleep 5 docker stack deploy --with-registry-auth --prune -c sslproxy/docker-compose-prod.yml sslproxy +REPLICA_COUNT=`docker service inspect sslproxy_app | jq '.[0].Spec.Mode.Replicated.Replicas'` +./timeout.sh -t 10 docker service scale sslproxy_app=`$REPLICA_COUNT * 2` docker service update -q sslproxy_app diff --git a/dockerfiles/services/timeout.sh b/dockerfiles/services/timeout.sh new file mode 100755 index 0000000..5c19d2e --- /dev/null +++ b/dockerfiles/services/timeout.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# The Bash shell script executes a command with a time-out. +# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal +# is blocked, then the subsequent SIGKILL (9) terminates it. +# +# Based on the Bash documentation example. + +# Hello Chet, +# please find attached a "little easier" :-) to comprehend +# time-out example. If you find it suitable, feel free to include +# anywhere: the very same logic as in the original examples/scripts, a +# little more transparent implementation to my taste. +# +# Dmitry V Golovashkin + +scriptName="${0##*/}" + +declare -i DEFAULT_TIMEOUT=9 +declare -i DEFAULT_INTERVAL=1 +declare -i DEFAULT_DELAY=1 + +# Timeout. +declare -i timeout=DEFAULT_TIMEOUT +# Interval between checks if the process is still alive. +declare -i interval=DEFAULT_INTERVAL +# Delay between posting the SIGTERM signal and destroying the process by SIGKILL. +declare -i delay=DEFAULT_DELAY + +function printUsage() { + cat < 0)); do + sleep $interval + kill -0 $$ || exit 0 + ((t -= interval)) + done + + # Be nice, post SIGTERM first. + # The 'exit 0' below will be executed if any preceeding command fails. + kill -s SIGTERM $$ && kill -0 $$ || exit 0 + sleep $delay + kill -s SIGKILL $$ +) 2> /dev/null & + +exec "$@" diff --git a/dockerfiles/tasks/apidocjs/Dockerfile b/dockerfiles/tasks/apidocjs/Dockerfile new file mode 100644 index 0000000..1aee236 --- /dev/null +++ b/dockerfiles/tasks/apidocjs/Dockerfile @@ -0,0 +1,13 @@ +# Using alpine linux for small image +# - http://gliderlabs.viewdocs.io/docker-alpine/ +FROM alpine:3.4 +MAINTAINER Richard Morgan +LABEL version=2.0 + +# install system packages +RUN apk --no-cache add \ + nodejs \ + && npm install apidoc -g + +WORKDIR /src + diff --git a/dockerfiles/tasks/apidocjs/build.sh b/dockerfiles/tasks/apidocjs/build.sh new file mode 100755 index 0000000..ca78734 --- /dev/null +++ b/dockerfiles/tasks/apidocjs/build.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +docker build --rm -f Dockerfile -t apidocjs:latest . +docker run --rm --entrypoint php apidocjs --version | grep 'PHP 7.2.' +docker tag apidocjs:latest dkregistry.xai-corp.net:5000/xaicorp/apidocjs:latest +docker push dkregistry.xai-corp.net:5000/xaicorp/apidocjs:latest