Commit 49545daa authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Fija nodo de clúster y actualiza CI

parent f29b6977
Loading
Loading
Loading
Loading

.env

0 → 100644
+1 −0
Original line number Diff line number Diff line
DESIRED_WORKER_ID=1
+25 −9
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ stages:
  - test-package
  - deploy

docker-build-dev:
docker-build-commit-non-master-branches:
  stage: package
  image: docker:stable
  variables:
@@ -19,7 +19,7 @@ docker-build-dev:
    - docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}-latest .
    - docker push ${CI_REGISTRY_IMAGE}

docker-build-pro:
docker-build-commit-master-branch:
  stage: package
  image: docker:stable
  variables:
@@ -33,7 +33,21 @@ docker-build-pro:
    - docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} -t ${CI_REGISTRY_IMAGE}:latest .
    - docker push ${CI_REGISTRY_IMAGE}

container_scanning:
docker-tag-already-built-image:
  stage: package
  image: docker:stable
  variables:
    DOCKER_DRIVER: overlay2
  services:
    - docker:dind
  only:
    - tags
  script:
    - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
    - docker tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
    - docker push ${CI_REGISTRY_IMAGE}

container-scanning:
  stage: test-package
  image: docker:stable
  variables:
@@ -44,7 +58,7 @@ container_scanning:
  only:
    - branches
  except:
    - master
    - schedules
  script:
    - docker run -d --name db arminc/clair-db:latest
    - docker run -p 6060:6060 --link db:postgres -d --name clair arminc/clair-local-scan:v2.0.1
@@ -55,11 +69,13 @@ 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]

deploy-postgresql-dev:
deploy-dev:
  stage: deploy
  image: registry.gitlab.com/redmic-project/docker/docker-deploy
  variables:
@@ -69,7 +85,7 @@ deploy-postgresql-dev:
    IMAGE_NAME: ${CI_REGISTRY_IMAGE}
    IMAGE_TAG: ${CI_COMMIT_SHA}
    COMPOSE_FILE: docker-compose.tmpl.yml:docker-compose.dev.yml
    STATUS_CHECK_DELAY: 240
    STATUS_CHECK_DELAY: 60
  services:
    - docker:dind
  script:
@@ -85,7 +101,7 @@ deploy-postgresql-dev:
    - master
  when: manual

deploy-postgresql-pro:
deploy-pro:
  stage: deploy
  image: registry.gitlab.com/redmic-project/docker/docker-deploy
  variables:
@@ -95,7 +111,7 @@ deploy-postgresql-pro:
    IMAGE_NAME: ${CI_REGISTRY_IMAGE}
    IMAGE_TAG: ${CI_COMMIT_SHA}
    COMPOSE_FILE: docker-compose.tmpl.yml:docker-compose.prod.yml
    STATUS_CHECK_DELAY: 240
    STATUS_CHECK_DELAY: 120
  services:
    - docker:dind
  script:
+2 −1
Original line number Diff line number Diff line
@@ -10,5 +10,6 @@ services:
volumes:
  postgres-data-vol:
    name: postgres-data-vol

  postgres-wal-vol:
    name: postgres-wal-vol
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ services:
      placement:
        constraints:
          - node.role == worker
          - node.labels.workerid == ${DESIRED_WORKER_ID}
      restart_policy:
        condition: on-failure
        max_attempts: 3
@@ -20,6 +21,7 @@ volumes:
      backing: relocatable
      size: 10
      ebstype: gp2

  postgres-wal-vol:
    name: "postgres-wal-vol"
    driver: "cloudstor:aws"
+5 −5
Original line number Diff line number Diff line
@@ -3,11 +3,6 @@ version: '3.5'
services:
  postgresql:
    image: ${IMAGE_NAME}:${IMAGE_TAG:-latest}
    environment:
      - ROLE=master
      - POSTGRES_PASSWORD
      - PGDATA=/var/lib/postgresql/data/db-files
      - POSTGRES_INITDB_WALDIR=/postgresql/wal/wal-files
    networks:
      postgres-net:
        aliases:
@@ -15,6 +10,11 @@ services:
    volumes:
      - postgres-data-vol:/var/lib/postgresql/data
      - postgres-wal-vol:/postgresql/wal
    environment:
      - ROLE=master
      - POSTGRES_PASSWORD
      - PGDATA=/var/lib/postgresql/data/db-files
      - POSTGRES_INITDB_WALDIR=/postgresql/wal/wal-files

networks:
  postgres-net: