GitLab CI/CD. Review Apps. .gitlab-ci.yml example with LXC containers deployment

ByDmitriy Altuhov

GitLab CI/CD. Review Apps. .gitlab-ci.yml example with LXC containers deployment

Just an exmaple of the .gitlab-ci.yml for CI/CD with branches deployment on the server with LXC containers.

We set GIT_STRATEGY = none, because we do not need GitLab Runner to pull the code from git, because, we have all magick in the python script (lxc_py.py). It do all the staff – create a new container, pull the code from git inside the container, start build inside the container and others.

stages: - reviewback - stagingback reviewback: stage: reviewback tags: - start variables: GIT_STRATEGY: none environment: name: reviewback/$CI_BUILD_REF_NAME url: https://api.$CI_BUILD_REF_SLUG.example.com on_stop: stop_reviewback auto_stop_in: 1 month script: - python3 /home/user/lxc/lxc_py.py $CI_BUILD_REF_NAME back start only: - branches except: - master stop_reviewback: variables: GIT_STRATEGY: none stage: reviewback when: manual environment: name: reviewback/$CI_BUILD_REF_NAME action: stop tags: - stop script: - python3 /home/user/lxc/lxc_py.py $CI_BUILD_REF_SLUG back stop staging: variables: GIT_STRATEGY: none stage: stagingback environment: name: stagingback url: https://api.example.com tags: - master script: - /home/user/scripts/start_back.sh only: - master
Code language: PHP (php)

About the author

Dmitriy Altuhov administrator