Commit 1b4912ba authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Merge branch 'dev' into 'master'

Contempla servicios completados en check deploy

See merge request redmic-project/docker/docker-deploy!28
parents 575af295 a925228a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
*
!script/**/*
!script
+11 −15
Original line number Diff line number Diff line
image: docker:stable

stages:
  - package
  - test-package

docker-build-development:
  stage: package
image: docker:stable

variables:
  DOCKER_DRIVER: overlay2

services:
  - docker:dind

docker-build-development:
  stage: package
  only:
    - branches
  except:
@@ -21,10 +23,6 @@ docker-build-development:

docker-build-stable:
  stage: package
  variables:
    DOCKER_DRIVER: overlay2
  services:
    - docker:dind
  only:
    - master
  script:
@@ -34,11 +32,7 @@ docker-build-stable:

container-scanning:
  stage: test-package
  variables:
    DOCKER_DRIVER: overlay2
  allow_failure: true
  services:
    - docker:stable-dind
  only:
    - branches
  script:
@@ -51,6 +45,8 @@ container-scanning:
    - mv clair-scanner_linux_amd64 clair-scanner
    - chmod +x clair-scanner
    - touch clair-whitelist.yml
    - ./clair-scanner -c http://docker:6060 --ip $(hostname -i) -r gl-sast-container-report.json -l clair.log -w clair-whitelist.yml ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} || true
    - >
      ./clair-scanner -c http://docker:6060 --ip $(hostname -i) -r gl-sast-container-report.json -l clair.log
      -w clair-whitelist.yml ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} || true
  artifacts:
    paths: [gl-sast-container-report.json]
+5 −4
Original line number Diff line number Diff line
@@ -2,10 +2,9 @@ FROM docker:latest

LABEL maintainer="info@redmic.es"

ENV DOCKER_COMPOSE_VERSION=1.21.2 \
	ALPINE_GLIBC_PACKAGE_VERSION="2.28-r0" \
	ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" \
	LANG=C.UTF-8
ARG ALPINE_GLIBC_PACKAGE_VERSION="2.28-r0"
ARG ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download"
ARG LANG=C.UTF-8

RUN ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
    ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
@@ -36,6 +35,8 @@ RUN ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk"
        "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME"

ARG DOCKER_COMPOSE_VERSION=1.23.2

RUN apk --update --no-cache add openssh-client && \
	wget \
		"https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" \
+22 −0
Original line number Diff line number Diff line
@@ -29,6 +29,28 @@ do
				stackServices=\$(docker service ls -f name=${serviceToCheck} --format '{{.Replicas}}') ; \
				serviceCount=\$(echo \"\${stackServices}\" | \${grepBin} -cE '.+') ; \
				runningServiceCount=\$(echo \"\${stackServices}\" | \${grepBin} -cE '([0-9]+)\/\1') ; \
				for j in \$(seq 1 ${runningServiceCount}) ; \
				do \
					runningServiceName=\$(docker service ls -f name=${serviceToCheck} --format '{{.Name}}') | \
						head -\${j} | tail -1 ; \
					runningServiceDesiredReplicas=\$(docker service ls -f name=\${runningServiceName} \
						--format '{{.Replicas}}' | cut -d '/' -f 2) ; \
					completedTaskCount=0 ; \
					for k in \$(seq 1 ${runningServiceDesiredReplicas}) ; \
					do \
						runningServiceStoppedTaskState=\$(docker service ps --format '{{.CurrentState}}' \
							-f 'desired-state=shutdown' -f \"name=\${runningServiceName}.\${k}\" \
							\${runningServiceName} | head -1 ; \
						if echo \"\${runningServiceStoppedTaskState}\" | grep 'Complete' ; \
						then \
							completedTaskCount=\$((\${completedTaskCount} + 1)) ; \
						fi ; \
					done ; \
				if [ \${completedTaskCount} -eq \${runningServiceDesiredReplicas} ] ; \
				then \
					runningServiceCount=\$((\${runningServiceCount} + 1)) ; \
				fi ; \
				done ; \
				statusCheckCmd=\"[ \"\${serviceCount}\" -ne \"0\" -a \
					\"\${serviceCount:-_}\" = \"\${runningServiceCount:--}\" ]\" ; \
			else \