Commit 38e25efc authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Deja de usar SERVICE como alternativa a STACK

Acaba con la duplicidad de STACK/SERVICE, heredada del uso de
docker-compose. Por el momento, se asume que se despliegan todos los
servicios definidos en los ficheros, al funcionar en modo
docker-compose.
Incluso para docker-compose, tiene sentido usar STACK a modo de nombre
del proyecto.
Actualiza documentación para reflejar que SERVICE se usa para la acción
de relaunch, solamente.
parent 77744f03
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -39,9 +39,10 @@ By script parameters you can set:

You may define these environment variables (**bold** are mandatory):

* **STACK** / **SERVICE**: Name of Docker stack (Swarm mode) or service (standard mode) to deploy.
* **STACK**: Name of Docker stack (Swarm mode) or project (docker-compose mode) used to wrap deployed services.
* **SSH_REMOTE**: SSH user and host of remote machine where you are going to deploy.
* **DEPLOY_KEY**: Private key paired with a public key accepted by remote machine, used to authenticate.
* *SERVICE*: Name of service to relaunch. **Required** for relaunch action.
* *ENV_PREFIX*: Prefix used to identify variables to be defined in remote environment (without this prefix). Default `DD_`.
* *ENV_SPACE_REPLACEMENT*: Unique string used to replace spaces into variable values while handling them. Default `<dd-space>`.
* *COMPOSE_FILE*: Name of docker-compose file with deployment definition. Multiple files are supported, separated by colon (`:`). Default `docker-compose.yml`.
+1 −1
Original line number Diff line number Diff line
#!/bin/sh

SERVICES_TO_CHECK="${SERVICES_TO_CHECK:-${STACK:-${SERVICE}}}"
SERVICES_TO_CHECK="${SERVICES_TO_CHECK:-${STACK}}"

echo -e "\n${INFO_COLOR}Checking deployment of services [${DATA_COLOR} ${SERVICES_TO_CHECK} ${INFO_COLOR}] at ${DATA_COLOR}${remoteHost}${INFO_COLOR} ..${NULL_COLOR}"

+0 −2
Original line number Diff line number Diff line
@@ -25,5 +25,3 @@ NULL_COLOR='\033[0m'
SSH_PARAMS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=error \
	-o "ControlPath=\"/ssh_connection_socket_%h_%p_%r\"" -o ControlMaster=auto \
	-o ControlPersist=${SSH_CONTROL_PERSIST}"

SCRIPTS_PATH="/usr/bin/"
+6 −5
Original line number Diff line number Diff line
@@ -16,12 +16,13 @@ deployCmd="\
		composeFileSplitted=\$(echo ${COMPOSE_FILE} | sed 's/:/ -c /g') && \
		${GREP_BIN} -v '^[#| ]' .env | sed -r \"s/(\w+)=(.*)/export \1='\2'/g\" > .env-deploy && \
		env -i /bin/sh -c \". \$(pwd)/.env-deploy && \
			docker stack deploy -c \${composeFileSplitted} \${deployAuthParam} ${STACK:-${SERVICE}}\" ; \
			docker stack deploy -c \${composeFileSplitted} \${deployAuthParam} ${STACK}\" ; \
	else \
		docker-compose stop ${SERVICE} && \
		docker-compose rm -f ${SERVICE} && \
		docker-compose pull ${SERVICE} && \
		docker-compose up -d ${SERVICE} ; \
		composeCmd=\"docker-compose -p ${STACK}\" ; \
		\${composeCmd} stop && \
		\${composeCmd} rm -f && \
		\${composeCmd} pull && \
		\${composeCmd} up -d ; \
	fi"

cleanDeployCmd="ssh ${SSH_PARAMS} \"${SSH_REMOTE}\" \"rm -rf ${DEPLOY_HOME}\""
+2 −2
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@ else
fi

echo -e "\n${INFO_COLOR}Setting environment variables to local and remote environments ..${NULL_COLOR}"
echo -en "  ${INFO_COLOR}variable names [ ${DATA_COLOR}SERVICE${INFO_COLOR}, ${DATA_COLOR}STACK${INFO_COLOR}"
echo -en "  ${INFO_COLOR}variable names [ ${DATA_COLOR}STACK${INFO_COLOR}"

envDefs="SERVICE=${SERVICE}\\nSTACK=${STACK}"
envDefs="STACK=${STACK}"

addVariableToEnv() {
	envDefs="${envDefs}\\n${1}"
Loading