Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

How to use Docker Container?

Set up of simple CI/CD

  1. Log in to gitlab.eufus.psnc.pl
  2. On the top bar, select Menu > Projects and find your project
  3. Press "+" button and select New File
  4. File must be in root of your repository and be called .gitlab-ci.yml
  5. Prepare content for CI / CD purposes - you can use simple example below as a template

    Note

    Executing script on Gateway is a little bit different than using Docker image. Please investigate carefully before_script section in example


    Code Block
    title.gitlab-ci.yml
    linenumberstrue
    stages:
      - Test Docker
    
    Execution inside Docker container:
      stage: Test Docker
      tags:
        - Docker
      image: 'gitlab.eufus.psnc.pl:5050/g2michal/imas-based-docker/ual-fc2k'
      before_script:
        - module load IMAS
        - imasdb test
        - tar -xf beaver-data/data/input/input.tar.gz -C $HOME/public/imasdb/test/3/0
      script:
        - make
        - ./bin/main


    Warning

    The ual-fc2k is a private repository. You have to request access in order to use Docker image


  6. Complete each section. Remember that each project has different requirements, so the commands must be adapted to your code.
    1. image - allows to specify a custom Docker image and a list of services that can be used for time of the build
    2. tags - The tag indicates whether the task is to be performed by HPC or Docker.
      Use Docker in this example. Using HPC is described here 



    3. before_script - is used to define the command that should be run before all builds, including deploy builds
    4. script - defines a shell script which is executed by Runner
    5. after_script is used to define the command that will be run after for builds
  7. At the end press Commit changes

How to check my CI/CD tasks?

Please visit this page

How to use external private repository inside Docker Container?

  1. Prepare your personal access token. A short tutorial is available here.
  2. Log in to gitlab.eufus.psnc.pl
  3. On the top bar, select Menu > Projects and find your project
  4. On the left sidebar, select Settings > CI/CD

  5. Expand Variables
  6. Click Add Variable
  7. Name the variable in Key field.
    Enter <your_gitlab_token>:<your_github_username> as the Value.

    Tip

    Remove Protect variable checkbox to use it in each tag or branch


    Warning

    Mark Mask variable to protect your confidential data from others.

    Access token serves the purpose of password.
    Be careful! If somebody intercepts your token all your repositories might be at risk! Do not share your access tokens!


  8. Press Add variable.
    If you performed the steps correctly, the list should display as below
  9. Update you .gitlab-ci.yml file to use variable with access token

    Code Block
    title.gitlab-ci.yml
    linenumberstrue
    stages:
      - Test Docker with access to external repository
    
    Execution inside Docker container:
      stage: Test Docker with access to external repository
      tags:
        - Docker
      image: 'gitlab.eufus.psnc.pl:5050/g2michal/imas-based-docker/ual-fc2k'
      before_script:
        - module load IMAS
        - imasdb test
        - git clone https://$CREDENTIALS@github.com/mkopsnc/beaver-data.git
        - tar -xf beaver-data/data/input/input.tar.gz -C $HOME/public/imasdb/test/3/0
      script:
        - make
        - ./bin/main


  10. Check your CI/CD pipelines. If everything is okay, job should be successful


...