Giter Club home page Giter Club logo

gitlab-ci-cd-pipeline's Introduction

CI-CD Pipeline Solution Overview

Explanations

(1) The developer makes changes in the web application then pushes those changes to master

(2) Gitlab communicates with the gitlab-runner that performes the actions defined in .gitlab-ci.yml, in the example :

(3) The gitlab-runner invoke the webhook defined in Portainer (Service section, don't forget to copy the URL to Gitlab CI variables)

(4) Once the webhook received, Portainer deploys the new version of the service (downloads the latest image from the docker hub then deploys it). Portainer communicate with the docker engine to do so

(5) The new version of the webapp is available for the browser

Implementation

CI CD Stack

docker-compose is used for this stack:

docker-compose up -d

Gitlab Runner Configuration

The file .gitlab-ci.yml should be present in gitlab repository root.

The command to register the runner :

docker run --rm -t -i -v $CONFIG_PATH:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner:latest register --non-interactive --executor "docker" --docker-image alpine:3 --url "http://192.168.43.41:8080/ci" --registration-token "EpHZLFMH-pcyV7ivR6Xm" --description "docker-runner" --tag-list "docker,aws" --run-untagged --locked="false"

Then start the runner :

docker run -d --name gitlab-runner --restart always -v $CONFIG_PATH:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest

To publish to docker hub, set the following variables :

CI_REGISTRY_USER=username
CI_REGISTRY_PASSWORD=********
CI_REGISTRY=docker.io
SONAR_TOKEN=token_generated_in_sonarqube

Docker host should be exposed, on centos 7:

Create the file : /etc/systemd/system/docker.service.d/docker-external.conf With content :

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

Then restart docker:

systemctl daemon-reload
systemctl restart docker

WebApp Installation

To deploy the webapp in swarm:

docker stack deploy -c webapp.yml webapp

gitlab-ci-cd-pipeline's People

Contributors

anaselhajjaji avatar

Stargazers

Weckwerth, Tom avatar  avatar OMID Zamani avatar

Watchers

James Cloos avatar  avatar

gitlab-ci-cd-pipeline's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.