User Tools

Site Tools


gitlab_ci_cd_documentation:cotrav-platform

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gitlab_ci_cd_documentation:cotrav-platform [2026/03/30 10:57] – [.gitlab-ci.yml] ravirajgitlab_ci_cd_documentation:cotrav-platform [2026/03/31 05:54] (current) – [Stage 1 — Test] raviraj
Line 1493: Line 1493:
  
 <code> <code>
 +test-auth
  
 </code> </code>
- 
-test-auth 
  
 This stage runs automated tests before building the service. This stage runs automated tests before building the service.
Line 1508: Line 1507:
 The job extends a reusable template: The job extends a reusable template:
  
-<code>extends: .base_test_job+<code> 
 +extends: .base_test_job
  
 </code> </code>
Line 1514: Line 1514:
 The runner used: The runner used:
  
-<code>tags:+<code> 
 +tags:
 - docker-runner01 - docker-runner01
  
Line 1520: Line 1521:
  
 ---- ----
 +
  
 ====== 4. Stage 2 — Build ====== ====== 4. Stage 2 — Build ======
Line 1809: Line 1811:
  
 <file> <file>
- 
 Cotrav_Services Cotrav_Services
  
Line 1827: Line 1828:
  
 Tools used: Tools used:
 +PNPM TurboRepo TypeScript
  
 </file> </file>
-  * 
-<file> 
-PNPM 
  
-</file> 
-  * 
 <file> <file>
-TurboRepo+include: 
 +  - local: gitlab/templates/test-service.yml 
 +  - local: gitlab/templates/build-service.yml 
 +  - local: gitlab/templates/validate-service.yml 
 +  - local: gitlab/templates/deploy-service.yml
  
-</file> +variables: 
-  * +  RUNNER_TAG: "docker-runner01" 
-<file> +  DOCKER_BUILDKIT: "1" 
-TypeScript+  MONOREPO_ROOT: "Cotrav_Services" 
 +  SERVICE_PATH: "Cotrav_Services/services/auth-service" 
 +  BASE_SERVICE_NAME: "auth-service" 
 +  VERSION_NUMBER: "V02" 
 +  DOCKER_IMAGE: "$CI_REGISTRY_IMAGE/auth-service" 
 +  DOCKER_TAG: "auth-service-${CI_COMMIT_REF_SLUG}-V02-${CI_COMMIT_SHORT_SHA}" 
 +  REMOTE_BASE_PATH: "/opt/cotrav/CICD_Pipeline" 
 +  ENV_CONTENT: "$AUTH_SERVICE_ENV_BASE64" 
 + 
 +stages: 
 +  - test 
 +  - build 
 +  - validate 
 +  - deploy 
 +  - cleanup 
 + 
 +cache: 
 +  key: "pnpm-cache-$CI_COMMIT_REF_SLUG" 
 +  paths: 
 +    - "Cotrav_Services/.pnpm-store" 
 +    - "Cotrav_Services/node_modules" 
 +    - "node_modules" 
 +  policy: pull-push 
 + 
 +.auth-service_rules: &auth_rules 
 +  rules: 
 +    - if: '$CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_BRANCH == "test" || $CI_COMMIT_BRANCH == "production"' 
 +      changes: 
 +        - "Cotrav_Services/packages/**/*" 
 +        - "Cotrav_Services/services/auth-service/**/*" 
 +        - "Cotrav_Services/pnpm-lock.yaml" 
 +        - "Cotrav_Services/package.json" 
 +# ... 
 + 
 +# ─── TEST ──────────────────────────────────────────────── 
 +test-auth: 
 +  extends: .base_test_job 
 +  tags: 
 +    - "$RUNNER_TAG" 
 +  <<: *auth_rules 
 + 
 +# ─── BUILD ─────────────────────────────────────────────── 
 +build-auth: 
 +  extends: .base_build_job 
 +  needs: ["test-auth"
 +  tags: 
 +    - "$RUNNER_TAG" 
 +  <<: *auth_rules 
 + 
 +# ─── VALIDATE ──────────────────────────────────────────── 
 +validate-auth: 
 +  extends: .base_validate_job 
 +  stage: validate 
 +  needs: 
 +    - job: build-auth 
 +      artifacts: true 
 +  tags: 
 +    - "$RUNNER_TAG" 
 +  <<: *auth_rules 
 + 
 +# ─── DEPLOY DEV ────────────────────────────────────────── 
 +deploy-dev: 
 +  extends: .base_deploy_job 
 +  needs: 
 +    - job: build-auth 
 +      artifacts: true 
 +    - job: validate-auth 
 +      artifacts: true 
 +  variables: 
 +    SERVICE_NAME: "auth-service" 
 +    TARGET_ENV: "dev" 
 +    DEPLOY_SERVER_IP: "$DEV_IP" 
 +    SSH_USER: "root" 
 +    PORT: "4001" 
 +    INTERNAL_PORT: "3000" 
 +  environment: 
 +    name: dev/auth-service 
 +  rules: 
 +    - if: '$CI_COMMIT_BRANCH == "dev"' 
 + 
 +# ─── DEPLOY TEST ───────────────────────────────────────── 
 +deploy-test: 
 +  extends: .base_deploy_job 
 +  needs: 
 +    - job: build-auth 
 +      artifacts: true 
 +    - job: validate-auth 
 +      artifacts: true 
 +  variables: 
 +    SERVICE_NAME: "auth-service" 
 +    TARGET_ENV: "test" 
 +    DEPLOY_SERVER_IP: "$DEV_IP" 
 +    SSH_USER: "root" 
 +    PORT: "4002" 
 +    INTERNAL_PORT: "3000" 
 +  environment: 
 +    name: test/auth-service 
 +  rules: 
 +    - if: '$CI_COMMIT_BRANCH == "test"' 
 +      when: manual 
 + 
 +# ─── DEPLOY PROD ───────────────────────────────────────── 
 +deploy-prod: 
 +  extends: .base_deploy_job 
 +  needs: 
 +    - job: build-auth 
 +      artifacts: true 
 +    - job: validate-auth 
 +      artifacts: true 
 +  variables: 
 +    SERVICE_NAME: "auth-service" 
 +    TARGET_ENV: "prod" 
 +    DEPLOY_SERVER_IP: "$DEV_IP" 
 +    SSH_USER: "root" 
 +    BLUE_PORT: "4003" 
 +    GREEN_PORT: "4004" 
 +    PORT: "4003" 
 +    INTERNAL_PORT: "3000" 
 +  environment: 
 +    name: prod/auth-service 
 +  rules: 
 +    - if: '$CI_COMMIT_BRANCH == "production"' 
 +      when: manual 
 + 
 +# ─── CLEANUP ───────────────────────────────────── 
 +cleanup-registry: 
 +  stage: cleanup 
 +  image: registry.gitlab.com/gitlab-org/cli:latest 
 +  script: 
 +    - echo "Cleaning up old images for $BASE_SERVICE_NAME" 
 +    - glab registry delete "$CI_PROJECT_PATH" --name "$BASE_SERVICE_NAME" --keep-n 5 --yes || true 
 +  rules: 
 +    - if: '$CI_COMMIT_BRANCH == "production"' 
 +      when: on_success 
 +  allow_failure: true
  
 </file> </file>
  
 ---- ----
 +
  
 ====== 17. Deployment Server ====== ====== 17. Deployment Server ======
gitlab_ci_cd_documentation/cotrav-platform.1774868238.txt.gz · Last modified: by raviraj