Docker Compose

Run with Docker-Compose

The docker-compose.yml contains:

Docker compose is very convenient to launch CDS for testing it. But this is not recommended for a Production Installation.

How to run

$ mkdir /tmp/cdstest && cd /tmp/cdstest
$ curl https://raw.githubusercontent.com/ovh/cds/master/docker-compose.yml -o docker-compose.yml
$ export HOSTNAME=$(hostname)

# Get the latest version
$ docker pull ovhcom/cds-ui:latest
$ docker pull ovhcom/cds-engine:latest

# Create PG database
$ docker-compose up --no-recreate -d cds-db

# check if DB is up
# check if last log is "LOG: database system is ready to accept connections"
$ docker-compose logs

$ docker-compose up --no-recreate cds-migrate
# You should have this log: "cds_cds-migrate_1 exited with code 0"

# run API, UI and hooks ┬Áservice
$ docker-compose up -d cds-api cds-ui cds-hooks

Open a browser on http://localhost:8080/account/signup, then register a new user admin, with an email admin@localhost.local for example. As there is no SMTP server configured in docker-compose.yml file, run docker-compose logs to get URL for validate the registration.

$ docker-compose logs|grep 'verify/admin'

After registration on UI, keep the password displayed, we will use it in next step.

Please note that the version linux/amd64, darwin/amd64 and windows/amd64 use libsecret / keychain to store the CDS Password. If you don’t want to use the keychain, you can select the version i386.

See: cdsctl documentation

You can download cdsctl CLI from http://localhost:8080/settings/downloads

# on a Linux workstation:
$ curl http://localhost:8081/download/cdsctl/linux/amd64 -o cdsctl
# on a osX workstation, it's curl http://localhost:8081/download/cdsctl/darwin/amd64 -o cdsctl
$ chmod +x cdsctl
$ ./cdsctl login --api-url http://localhost:8081 -u admin
CDS API URL: http://localhost:8081
Username: admin
Password:
          You didn't specify config file location; /Users/yourhome/.cdsrc will be used.
Login successful
$ ./cdsctl user me
CDS API:http://localhost:8081
email       admin@localhost.local
username    admin
fullname    Administrator
$ ./cdsctl template push https://raw.githubusercontent.com/ovh/cds/master/contrib/workflow-templates/demo-workflow-hello-world/demo-workflow-hello-world.yml
Workflow template shared.infra/demo-workflow-hello-world has been created
Template successfully pushed !
$ ./cdsctl project create DEMO FirstProject
$ ./cdsctl workflow applyTemplate
? Found one CDS project DEMO - FirstProject. Is it correct? Yes
? Choose the CDS template to apply: Demo workflow hello world (shared.infra/demo-workflow-hello-world)
? Give a valid name for the new generated workflow MyFirstWorkflow
? Push the generated workflow to the DEMO project Yes
Application MyFirstWorkflow successfully created
Application variables for MyFirstWorkflow are successfully created
Permission applied to group FirstProject to application MyFirstWorkflow
Environment MyFirstWorkflow-prod successfully created
Environment MyFirstWorkflow-dev successfully created
Environment MyFirstWorkflow-preprod successfully created
Pipeline build-1 successfully created
Pipeline deploy-1 successfully created
Pipeline it-1 successfully created
Workflow MyFirstWorkflow has been created
Workflow successfully pushed !
.cds/MyFirstWorkflow.yml
.cds/build-1.pip.yml
.cds/deploy-1.pip.yml
.cds/it-1.pip.yml
.cds/MyFirstWorkflow.app.yml
.cds/MyFirstWorkflow-dev.env.yml
.cds/MyFirstWorkflow-preprod.env.yml
.cds/MyFirstWorkflow-prod.env.yml

Before running your new Workflow, we have to create a worker model and start a Hatchery for spawning workers.

$ ./cdsctl worker model import https://raw.githubusercontent.com/ovh/cds/master/contrib/worker-models/go-official-1.11.4-stretch.yml
Worker model go-official-1.11.4-stretch imported with success

The docker-compose.yml runs hatchery belonging to the shared.infra groups.

Please check that your Docker installation allows Docker API calls on tcp://${HOSTNAME}:2375 Otherwise, please update environment variable DOCKER_HOST: tcp://${HOSTNAME}:2375 in docker-compose.yml

$ export HOSTNAME=$(hostname)
$ # For osX user run this container. This will allow hatchery:swarm to communicate with your docker daemon
$ docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 2375:2375 bobrik/socat TCP4-LISTEN:2375,fork,reuseaddr UNIX-CONNECT:/var/run/docker.sock
$ docker-compose up -d cds-hatchery-swarm

A swarm hatchery spawns CDS Workers inside dedicated containers. This ensures isolation of the workspaces and resources.

$ ./cdsctl workflow run DEMO MyFirstWorkflow
Workflow MyFirstWorkflow #1 has been launched
http://localhost:8080/project/DEMO/workflow/MyFirstWorkflow/run/1

on http://localhost:8080/project/DEMO/workflow/MyFirstWorkflow/run/1 you will have

Workflow Generated

You see that the pipeline deploy in production was not launched automatically. There is a Run Condition on it cds.manual = true:

Run Condition

The build pipeline contains two stages, with only one job in each stage

Build Pipeline

Next with Actions, Plugins

$ ./cdsctl action import https://raw.githubusercontent.com/ovh/cds/master/contrib/actions/cds-docker-package.yml

Go further