Développement Web à partir de zéro: un guide pour les jeunes équipes sur la création d'une infrastructure CI / CD et d'un processus de développement

Il y a un peu plus d'un an, j'ai été confronté au fait que tout un département de développement web a grandi sur un projet interne d'une société totalement non-IT, que j'ai eu la chance de diriger. Le flux de travail semblait s'installer et convenait à tout le monde, mais des problÚmes persistaient:



  • Chaque succursale a Ă©tĂ© vĂ©rifiĂ©e localement. J'ai dĂ» faire reculer la base des modifications du contrĂŽle prĂ©cĂ©dent, construire l'avant. Lorsque plusieurs dĂ©veloppeurs Ă©taient sur le point de terminer le travail et qu'il restait Ă  vĂ©rifier chacune des petites choses, cela s'est transformĂ© en enfer;
  • Les environnements de production et entre les dĂ©veloppeurs diffĂ©raient, ce qui entraĂźnait des erreurs: «tout fonctionne pour moi».


Le perfectionniste intérieur voulait faire les choses correctement. Je partage les résultats de ma recherche d'une réponse à la question: "comment, en fait, est" correct ""?



Nous avons réalisé



  • DĂ©ploiement facile et rapide en production (Ă  titre expĂ©rimental, ils ont Ă©tĂ© affichĂ©s tous les jours pendant deux semaines consĂ©cutives);
  • Une garantie de protection contre les erreurs dues aux diffĂ©rences dans l'environnement d'application;
  • Nous pouvons organiser une interaction efficace avec le client:

    • dĂ©montrer chaque branche de fonctionnalitĂ©;
    • donnez aux invitĂ©s l'accĂšs pour crĂ©er des tĂąches et surveiller la progression du travail.


, :



  • 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



  • https://docs.traefik.io/


reverse proxy + SSL nginx



  • https://habr.com/ru/post/328048/
  • https://habr.com/ru/post/445448/
  • https://github.com/jwilder/nginx-proxy
  • https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion


GitLab



  • https://docs.gitlab.com/omnibus/docker


GitLab SSL config



  • https://docs.gitlab.com/omnibus/settings/ssl.html
  • reverse-proxy https://docs.gitlab.com/omnibus/settings/nginx.html#supporting-proxied-ssl


GitLab Registry



  • https://docs.gitlab.com/ce/administration/container_registry.html#configure-container-registry-under-its-own-domain
  • : https://docs.gitlab.com/omnibus/maintenance/#container-registry-garbage-collection


Gitlab-runner



  • https://docs.gitlab.com/runner/install/docker.html
  • Docker Executor https://docs.gitlab.com/runner/executors/docker.html
  • SSH Executor https://docs.gitlab.com/runner/executors/ssh.html
  • https://docs.gitlab.com/runner/register/index.html#docker
  • Docker GitLab CI/CD https://docs.gitlab.com/ce/ci/docker/using_docker_build.html
  • Docker Docker priveleged mode registry

    ( ) https://docs.gitlab.com/ce/ci/docker/using_kaniko.html
  • https://docs.gitlab.com/runner/configuration/advanced-configuration.html
  • CLI https://docs.gitlab.com/runner/commands/README.html


Docker



  • https://docs.docker.com/install/linux/linux-postinstall/
  • docker-compose https://docs.docker.com/compose/reference/overview/
  • https://docs.docker.com/compose/reference/config/
  • Docker (TCP + TLS): https://docs.docker.com/engine/security/https/




  • -: https://github.com/wagoodman/dive



    #    docker  (   )
    sudo docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive:latest gitlab/gitlab-runner:latest


  • SSL: https://ssl-config.mozilla.org/#server=traefik&server-version=2.1&config=intermediate



  • GitLab Shell Runner. docker-compose https://habr.com/ru/post/449910



  • :



    • https://t.me/ru_gitlab
    • https://t.me/ru_docker
    • https://t.me/PostgreSQL_1C_Linux
    • https://t.me/werf_ru


  • ""






All Articles