indigo-dc / jenkins-pipeline-library

Jenkins pipeline library with common functionalities for CI/CD environments, mainly targeted for the implementation of the SQA baseline requirements from https://indigo-dc.github.io/sqa-baseline/
Apache License 2.0
11 stars 6 forks source link

Common services definition #49

Closed samuelbernardolip closed 4 years ago

samuelbernardolip commented 4 years ago

For common services like database, dataverse, workload managers, they can be automatically added to the Compose agent as available components. To use this concept, it needs to be defined a special context in config called service that will be added to the compose configuration. They will use available docker images from dockerhub registry. It can be implemented answering to the follow example:

config:
  project_repos:
    worsica-processing:
      repo: 'https://github.com/WORSICA/worsica-processing.git'
      branch: master
      dockerhub: worsica/worsica-processing
      dockertag: latest
  services:
    - db1:
        type: postgres
        version: 12.1
        environment:
          - PGPORT: 5432:5432
          - POSTGRES_PASSWORD: ${from_configCredentials1}
    - db2:
        type: postgres
        version: 12.1
        environment:
          - PGPORT: 5432:5432
          - POSTGRES_PASSWORD: ${from_configCredentials2}
    - fair_repo:
        type: dataverse
        version: 4.20
        environment:
          - SOLR_PORT: 8983
          - ADMIN_PORT: 4848
          - API_PORT: 8000
          - PORTAL_PORT:443
          - ADMIN_EMAIL: admin@localhost
          - MAIL_SERVER: mailrelay
          - POSTGRES_ADMIN_PASSWORD: ${from_configCredentials3}
          - POSTGRES_USER: dvnapp
          - RSERVE_PASSWORD: ${from_configCredentials4}

sqa-criteria:
  qc-style:
    repos:
      worsica-processing:
        container: processing
        tox:
          testenv:
            - stylecheck

environment:
  GIT_COMMITTER_NAME: Person1
  GIT_COMMITTER_EMAIL: person1@example.org
  LANG: C.UTF-8

timeout: 600

In the previous example the service hostnames would be:

When using config.services this will not be available to run commands or referencing as container in sqa_criteria. The user can use the environment variables to configure the services as defined by referenced images. The environment variables can be defined at two different levels:

For current Docker Compose Agent is possible to use extends to merge the configurations as overrides or importing multiple configuration files: https://docs.docker.com/compose/extends/

orviz commented 4 years ago

The services setting will not be implemented since we will leverage entirely in the capabilities of the underlying container orchestrator, i.e. Docker Compose (or k8s in the future).

What we need to provide is elaborated examples on how to manage specific types of services using docker-compose.yml such as the ones in the example (postgres, dataverse, ..)