Commit 52604491 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Merge branch 'dev' into 'master'

Corrige copia de ficheros de despliegue

See merge request redmic-project/docker/docker-deploy!15
parents 5ef99177 5aa2184e
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -10,8 +10,7 @@ do
	echo -e "  ${INFO_COLOR}retries ${DATA_COLOR}${STATUS_CHECK_RETRIES}${INFO_COLOR}, interval ${DATA_COLOR}${STATUS_CHECK_INTERVAL}${INFO_COLOR}s, hits ${DATA_COLOR}${STATUS_CHECK_MIN_HITS}${NULL_COLOR}"

	checkDeployCmd="\
		docker stack ls > /dev/null 2> /dev/null ; \
		if [ \"\${?}\" -eq \"0\" ] ; \
		if docker stack ls > /dev/null 2> /dev/null ; \
		then \
			swarmMode=true ; \
		fi ; \
@@ -42,8 +41,7 @@ do
				statusCheckCmd=\"[ \${serviceContainerId:-_} = \${runningService:--} -o \
					\${serviceContainerId:-_} = \${successfullyExitedService:--} ]\" ; \
			fi ; \
			eval \"\${statusCheckCmd}\" ; \
			if [ \"\${?}\" -eq \"0\" ] ; \
			if eval \"\${statusCheckCmd}\" ; \
			then \
				echo -e \"${PASS_COLOR}[PASS]${NULL_COLOR}\" && \
				hits=\$((\${hits} + 1)) && \
+9 −10
Original line number Diff line number Diff line
@@ -5,20 +5,19 @@ echo -e "\n${INFO_COLOR}Deploying at remote target ..${NULL_COLOR}\n"
deployCmd="\
	cd ${DEPLOY_HOME} && \
	docker login -u ${REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY} && \
	docker stack ls > /dev/null 2> /dev/null ; \
	if [ \"\${?}\" -ne \"0\" ] ; \
	if docker stack ls > /dev/null 2> /dev/null ; \
	then \
		composeFileSplitted=\$(echo ${COMPOSE_FILE} | sed 's/:/ -c /g') && \
		env -i \$(grep -v '^#\\| ' .env | xargs) \
			docker stack deploy -c \${composeFileSplitted} --with-registry-auth ${STACK:-${SERVICE}} ; \
	else \
		docker-compose stop ${SERVICE} && \
		docker-compose rm -f ${SERVICE} && \
		docker-compose pull ${SERVICE} && \
		docker-compose up -d ${SERVICE} && \
		rm ${DEFAULT_DEPLOY_FILES} ; \
	else \
		composeFileSplitted=\$(echo ${COMPOSE_FILE} | sed 's/:/ -c /g') && \
		env -i \$(grep -v '^#\\| ' .env | xargs) \
			docker stack deploy -c \${composeFileSplitted} --with-registry-auth ${STACK:-${SERVICE}} && \
		rm ${DEFAULT_DEPLOY_FILES} ; \
	fi\
		docker-compose up -d ${SERVICE} ; \
	fi ; \
	cd .. && \
	rm -rf ${DEPLOY_HOME}\
"

ssh ${SSH_PARAMS} "${SSH_REMOTE}" "${deployCmd}"
+6 −5
Original line number Diff line number Diff line
@@ -27,16 +27,17 @@ echo -e "\n${INFO_COLOR}Checking deploy configuration in docker-compose files ..
echo -e "  ${INFO_COLOR}compose files [ ${DATA_COLOR}${COMPOSE_FILE}${INFO_COLOR} ]${NULL_COLOR}"

# Antes de continuar, se comprueba que la configuración de despliegue sea válida.
docker-compose config > /dev/null
if [ "${?}" -ne "0" ]

if docker-compose config > /dev/null
then
	echo -e "${PASS_COLOR}Valid docker-compose configuration!${NULL_COLOR}"
else
	echo -e "${FAIL_COLOR}Invalid docker-compose configuration!${NULL_COLOR}"
	exit 1
else
	echo -e "${PASS_COLOR}Valid docker-compose configuration!${NULL_COLOR}"
fi

DEPLOY_HOME="${DEPLOY_PATH}/docker/${STACK:-${SERVICE}}"
randomValue="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)"
DEPLOY_HOME="${DEPLOY_PATH}/docker-deploy/${randomValue}"

echo -e "\n${INFO_COLOR}Sending deploy resources to remote ..${NULL_COLOR}"
echo -e "  ${INFO_COLOR}deploy path [ ${DATA_COLOR}${DEPLOY_HOME}${INFO_COLOR} ]${NULL_COLOR}"
+1 −2
Original line number Diff line number Diff line
@@ -21,8 +21,7 @@ createNetsCmd="${createNetsCmd} :"

createNetsInRemoteCmd="\
	createNetCmd=\"docker network create\" && \
	docker stack ls > /dev/null 2> /dev/null ; \
	if [ \"\${?}\" -eq \"0\" ] ; \
	if docker stack ls > /dev/null 2> /dev/null ; \
	then \
		createNetCmd=\"\${createNetCmd} -d overlay --attachable\" ; \
	fi ; \