Giter Club home page Giter Club logo

gitlab-docker-cpp-hello's Introduction

C++ Project building, testing and Docker image creating with Docker executor on a local Gitlab server

Step 0:

  • Install docker for your OS (Windows, macOS or Linux)
  • Install Gitlab CE and Gitlab-Runner for your OS or you can use Gitlab docker images, if no install is available (Windows, macOS)
  • Register Gitlab runners for your Gitlab server (yu need your Gitlab server URL and token)
  • I use 2 Gitlab runners:
    • A runner for building and testing the project (tags: cxx, )
    • A runner for building project Docker image

Here is my runners /etc/gitlab-runner/config.toml:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "local-runner"
  url = "http://ubudesk/"
  token = "Ye-Fds4-gUATLH85Vkwp"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    tls_verify = false
    image = "ubuntu:18.04"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    pull_policy = "if-not-present"
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

[[runners]]
  name = "docker-deploy"
  url = "http://ubudesk/"
  token = "fgLYQhZG-ndwffxXZ7As"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    tls_verify = false
    image = "docker:stable"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0
    pull_policy = "if-not-present"
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

Step 1: Build Docker GCC build image (tagged alpine-gcc:3.9)

bash
docker build -t alpine-gcc:3.9 -f Dockerfile.build .

C++ Project development:

  • Modify the project and push changes to Gitlab server.
  • Gitlab server will run your CI/CD stages:
    • build: build your C++ project
    • test: test your C++ project
    • image: create Docker image
  • A Docker image will be created and tagged helloapp:latest, you can test it by:
bash
docker run helloapp:latest
  • The output:
Hello World!

Todo

  • Add a stage to deploy your Docker image to a server, Docker hub, etc...

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.