Code Monkey home page Code Monkey logo

common_ci_scripts_for_dockerhub_release's Introduction

Build Status Sonar Coverage Sonar Maintainability Docker Image

Sample CI/CD project with dockerhub integration

This project shows how to setup a pipeline using CI services like GitLab or Travis CI to:

  • build and test a (C++/Java/etc) multiarch (amd64/arm64) project using specific docker images;
  • produce and send coverage info to sonarcloud.io;
  • build a docker image, tag and push it to hub.docker.com;
  • create the git tag related with the build and push it back to your repository.

CI Rules:

  1. not-master branch:
    • build, test, coverage
  2. master branch:
    • build, test, coverage
    • ensure uniqueness and push a new git tag
    • build and pus docker image

CI requirements:

  • docker repository (hub.docker.com) push access
  • git remote (gitlab.com) push access
  • sonarcloud.io bind

Configuration:

  1. configure the follows pipeline environment variables:

    • DOCKER_USERNAME
    • DOCKER_PASSWORD
    • DOCKER_REPOSITORY
    • GIT_USERNAME
    • GIT_PASSWORD
    • GIT_EMAIL
    • GIT_REPOSITORY_URL
    • SONAR_ORGANIZATION
    • SONAR_TOKEN
    • SONAR_PROJECT

    Step by step howto:

     1 - GitLab access
       login with your account on gitlab.com and go to -> user-icon -> Edit profile -> Access Tokens
         create a new Token (with read_repository and write_repository scopes) to allow CI pipeline to push tags into GitLab  (suggested name: "CI push")
       go to gitlab.com  -> your project -> Settings -> CI/CD -> Variables Expand
         add the follow env vars:
         - GIT_REPOSITORY_URL (not masked) containing the GitLab repository to push tags (e.g. gitlab.com/campisano/common_ci_scripts_for_dockerhub_release)
         - GIT_EMAIL          (not masked) containing a email for commit logs            (e.g. cipush@gitlab)
         - GIT_USERNAME       (not masked) containing the fixed GitLab username          (exactly gitlab-ci-token, see https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)
         - GIT_PASSWORD       (masked)     containing the GitLab Personal access token   (e.g. the previously created)
    
     2 - Docker Hub access
       login with your account on hub.docker.com and go to -> Account Settings -> Security
         create a new Access Token to allow CI pipeline to push images into Docker Hub (suggested description: "CI push")
       go to gitlab.com  -> your project -> Settings -> CI/CD -> Variables Expand
         add the follow env vars:
         - DOCKER_REPOSITORY (not masked) containing the Docker Hub repository to push images (e.g. riccardocampisano/public)
         - DOCKER_USERNAME   (not masked) containing your Docker Hub username                 (e.g. riccardocampisano)
         - DOCKER_PASSWORD   (masked)     containing the Docker Hub Access Token              (e.g. the previously created)
    
     3 - SonarCloud access
       login with your account on sonarcloud.io and go to -> user-icon -> My Account -> Security
         create a new Token to allow CI pipeline to push code analisys into SonarCloud (suggested name: "CI push")
       go to gitlab.com  -> your project -> Settings -> CI/CD -> Variables Expand
         add the follow env vars:
         - SONAR_ORGANIZATION (not masked) containing the SonarCloud organization key  (e.g. campisano)
         - SONAR_PROJECT      (not masked) containing a SonarCloud key for the project (e.g. common_ci_scripts_for_dockerhub_release)
         - SONAR_TOKEN        (masked)     containing the SonarCloud Token             (e.g. the previously created)
    
  2. edit the scripts in the ./ci/custom folder

Screenshots:

Required pipeline env vars

Alt text

Resulting pipeline builds

Alt text

Resulting dockerhub images

Alt text

common_ci_scripts_for_dockerhub_release's People

Contributors

campisano avatar

Watchers

 avatar  avatar

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.