Web Development from Scratch: A Guide for Young Teams on Building a CI / CD Infrastructure and Development Process

A little over a year ago, I was faced with the fact that an entire web development department grew up on an internal project of a completely non-IT company, which I had a chance to lead. The workflow seemed to settle down and was fine with everyone, but problems remained:



  • Each branch was checked locally. I had to roll back the base from the changes from the previous check, build the front. When several developers were about to finish the work and it was left to check each of the little things - it turned into hell;
  • The environments on production and between the developers differed, which led to errors: β€œeverything works for me”.


The inner perfectionist longed to organize everything right. I am sharing the results of my search for an answer to the question: β€œhow, in fact, isβ€œ correct ””?



We have achieved



  • Easy and fast deployment in production (for the sake of experiment, they were displayed every day for two weeks in a row);
  • A guarantee of protection against errors due to differences in the application environment;
  • We can organize effective interaction with the customer:

    • demonstrate each feature branch;
    • give guest access to create tasks and monitor the progress of work.


, :



  • IT- ;
  • (workflow);
  • , ;
  • DevOps, CI/CD, , , .




  • ;
  • ;
  • : -;
  • , .




:



  • ;
  • ;
  • -.


,



, , . -, , , (- DevOps).

, , : β€œ, , ?”.



β€œβ€ , . , . , . .



, , , . , , β€œbest practices”. -.



, , , , -.



, .



:



  • - . , ;
  • , , ;
  • , git, Linux, Docker, GitLab, Traefik.






1. git





A successful Git branching model by Vincent Driessen



β€” : master, dev feature.



Feature

feature- / , dev-. , dev.



Dev

dev , master.



Master

production-. , , hotfix-, .

Master dev , .



2. . .





. feature , . β€œ, xxx” , , . Merge Request- . wiki , .



, - β€” .

GitLab, , .



3.



β€” , . , //.



, IT- , DevOps. . . , . - (LXC), Docker, ...





, . , , . , . , - , . , , , .





, , , , , β€” . , .





, , . ( ) , , , , , . . , , β€œ ”. .



/



, - , . , , . . , .



UI/UX



, . ( Microsoft, ).





. . .





, , , , . .





. - .



: , , .., .



(QA / QC)



Quality Control (QC) . , . Quality Assurance (QA) , ( Toyota β€” ). , docker-, , .



(DevOps)



, . , .







workflow



  1. - (feature) , . .
  2. . . . , .
  3. , ( ), , , . β€” .
  4. feature- dev , , . , feature-, . , .

    : , , , . , , , merge-request.

  5. merge-request dev-, , feature-.
  6. , . β€” -, , .
  7. feature- dev.
  8. , dev- merge-request master 5, 6 .
  9. 7, .
  10. , ( changelog-), . .
  11. , production.
  12. . .




:



  • production-ready
  • ( )


: Traefik, GitLab Docker.





  • 3 [Production], [Staging] [Services]. , , . /. , [Production] . [Services] GitLab (, docker registry: Portainer, ELK, Harbor, etc), Services. . Docker-. GitLab , .
  • Traefik DNS- *.dev.company.ru, [Staging] TCP . SSL [Production]. Wildcard (WC) *dev.company.ru letsencrypt-dns, DNS- Traefik. Traefik , SSL http . [Production] App.
  • GitLab [Services] GitLab-runner-, , Merge Request- () dev master, - [Staging] [Production] .gitlab-ci.yml .
  • , [Staging].
  • GitLab Docker Registry, .
  • GitLab, Traefik Gitlab-runner- docker-, .


github-, . , :



https://github.com/Akkarine/demo_cicd





  • , . . , Enterprise Traefik GitLab .
  • , . , , , ..
  • , Traefik GitLab . , Traefik DNS Yandex ( ) . GitLab . , rules.
  • β€œ ”.




-



https://github.com/Akkarine/demo_cicd_project



-, , :



  • . downtime ( API , ), load-balancer- , β€” β€” kubernetes. β€œ ”
  • ( )
  • production- ( , )
  • root ( )


β€” .gitlab-ci.yml. pipeline- :



  • base-img-rebuild

    • rebuild-base-backend

      . β€” , , . ( build), .
  • rebuild-dev-db

    • rebuild-dev-db

      , .
  • build

    • rebuild-proxy-img

      - nginx , latest
    • build-backend

      , ( GitLab)
  • test

    • testing

  • deploy-review

    • deploy_review

      , production, , .
  • skip_review

    , , .
  • review

    • approve-dev

      . Merge-request dev (.. β€” feature), . .
    • approve-staging

      . Merge-request master (.. β€” hotfix dev ), build latest . , latest , β€” .
    • reject

      . . Merge Request- , - .
    • stop_review

      , . .
  • rebuild-approved-db-img

    • rebuild-approved-db-img

      review , latest .
  • deploy-prod

    • deploy-production

      latest. , .
    • deploy-production-wo-containers

      , , .
  • clear

    staging production

    • clean-staging
    • clean-prod
  • restore-db

    • restore-db

      β€” .


, . β€” , . , .







Traefik





reverse proxy + SSL nginx





GitLab





GitLab SSL config





GitLab Registry





Gitlab-runner





Docker










All Articles