Skip to content

Commit

Permalink
chore (*): docker-compose (#579)
Browse files Browse the repository at this point in the history
* chore: docker-compose file

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>

* doc: title

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>

* Update run-with-docker-compose.md

* chore: use caddy built from master

Signed-off-by: Yvonnick Esnault <yvonnick@esnau.lt>
  • Loading branch information
yesnault authored and fsamin committed Apr 29, 2017
1 parent 27d62c1 commit 8b75f90
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 10 deletions.
14 changes: 6 additions & 8 deletions doc/overview/introduction.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## What is CDS?

CDS is a Continuous Delivery solution with an architecture featuring:

* A complete isolation between tenants
* High availability oriented architecture
* Automatic scaling
* Automation oriented with iso-feature API, CLI and WebUI

Designed for scalability, CDS tasks can run either on cloud infrastructure or on your own machines, should you start some workers using a [hatchery](/doc/overview/hatchery.md).
Designed for scalability, CDS tasks can run either on cloud infrastructure or on your own machines, should you start some workers using a [hatchery](/doc/overview/hatchery.md).

CDS exposes an API available to [workers](/doc/overview/worker.md) and humans through cli or WebUI.

Expand All @@ -33,7 +33,7 @@ An application is composed of one or multiple pipelines, that can be triggered:
* Declaration of worker models (specific hosts, docker image, openstack recipe)
* Conditional build path depending of build parameters (ie: git branch)

### Deployment
### Deployment

* Completely cross platform workers (built in Go) without any dependency
* Support for deployment environments (different sets of variable for the same deployment pipeline)
Expand All @@ -58,17 +58,14 @@ On this view, you can see how an application attaches pipelines and environment

### Action requirements and worker capabilities

CDS is built on simples principes:
CDS is built on simples principles:

* Any client operation is an Action and has requirements.
* Every worker registered has capabilities and build if and only if all requirements are met.


![Action and Workers](/doc/img/action-worker.png)


Relation between workers and actions.

Relation between workers and actions.

### Harness PaaS with worker models and [hatcheries](/doc/overview/hatchery.md)

Expand All @@ -93,4 +90,5 @@ We wanted a CD ecosystem where workers are easy to setup anywhere.

## Next Steps

* [Run with Docker-Compose](/doc/tutorials/run-with-docker-compose.md)
* [Quick start](/doc/overview/quickstart.md)
72 changes: 72 additions & 0 deletions doc/tutorials/run-with-docker-compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
## Run with Docker-Compose

The [docker-compose.yml](/docker-compose.yml) contains:
- cds-db service with a postgresql
- cds-cache service with a redis
- cds-migrate service to prepare DB tables.
- cds-api service
- cds-ui service
- cds-hatchery-swarm service
- cds-hatchery-local service

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

## How to run

```bash
$ git clone https://github.com/ovh/cds.git
cd cds
export HOSTNAME=$(hostname)

# 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 last API and UI
docker-compose up cds-api cds-ui

```

Open a browser on http://localhost:2015, then register a new user.
As there is no SMTP server configured in docker-compose.yml file,
run `docker-compose logs` to get URL for validate the registration.

## Prepare Project, Pipeline and Application

On UI:

- Create a project
- Create an application, with an void pipeline
- Create a pipeline, with a stage and a job
- Inside job, add a step of type "script"
- In script content, add theses lines:
```bash
#!/bin/bash
set -ex
echo "foo"
sleep 10
echo "bar"
```

## Run Pipeline

Run pipeline. As you can see now, you pipeline is in "waiting status". You have
to run a CDS Worker or a CDS Hatchery which aims to create workers.

Let's run an hatchery with docker-compose. Two ways:
- a containers with a hatchery `local`. Workers will be spawn inside this container.
- a containers with a hatchery `swarm`. Each worker will be in their own container.

If your host expose docker API, you can run `docker-compose up cds-hatchery-swarm`

Otherwise, you can run `docker-compose up cds-hatchery-local`

*Running a hatchery "local" in a container is not recommanded. Use this way only for test purpose*.

After running a Hatchery, your pipeline will be in "Building" status, then "Success" status.
112 changes: 112 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
version: '3'

services:
cds-db:
image: postgres:9.6.2
environment:
POSTGRES_PASSWORD: cds
POSTGRES_USER: cds

cds-cache:
image: redis:alpine
command: redis-server --requirepass cds
ports:
- "6379:6379"

cds-migrate:
image: ovhcom/cds-api:latest
command: /app/api-linux-amd64 database upgrade --db-host cds-db --db-user cds --db-password cds --db-name cds --db-sslmode disable --migrate-dir /app/sql
links:
- cds-db

cds-api:
image: ovhcom/cds-api:latest
command: /app/api-linux-amd64
volumes:
- cds-artefacts-volume:/app/artefacts
environment:
CDS_VCS_REPOSITORIES_GITHUB_STATUSES_URL_DISABLED: "true"
CDS_VCS_REPOSITORIES_GITHUB_STATUSES_DISABLED: "true"
CDS_VCS_REPOSITORIES_CACHERLOADER_DISABLED: "true"
CDS_VCS_REPOSITORIES_BITBUCKET_STATUSES_DISABLED: "true"
CDS_DB_HOST: cds-db
CDS_DB_PASSWORD: cds
CDS_DB_TIMEOUT: 10000
CDS_DB_USER: cds
CDS_DB_NAME: cds
CDS_DB_MAXCONN: 40
CDS_DB_PORT: 5432
CDS_DB_SSLMODE: disable
CDS_URL_API: ${HOSTNAME}:8081
CDS_URL_UI: ${HOSTNAME}:8080
CDS_SMTP_DISABLE: "true"
CDS_SMTP_TLS: "false"
CDS_SMTP_FROM: noreply.cds@foo.cds
CDS_SMTP_HOST: smtp.foo.cds
CDS_SMTP_PORT: 25
CDS_AUTH_LOCALMODE: session
CDS_AUTH_LDAP_ENABLE: "false"
CDS_AUTH_DEFAULTGROUP: cdsdemo
CDS_LOG_LEVEL: info
CDS_SERVER_HTTP_SESSIONTTL: 600
CDS_CACHE_TTL: 60
CDS_CACHE_REDIS_HOST: cds-cache:6379
CDS_CACHE_REDIS_PASSWORD: cds
CDS_CACHE_MODE: redis
CDS_DIRECTORIES_DOWNLOAD: /app
CDS_VCS_POLLING_DISABLED: "false"
CDS_SERVER_HTTP_PORT: 8081
CDS_SERVER_GRPC_PORT: 8082
CDS_SCHEDULERS_DISABLED: "false"
CDS_DIRECTORIES_KEYS: /app/keys
CDS_ARTIFACT_MODE: local
CDS_ARTIFACT_LOCAL_BASEDIR: /app/artefacts
CDS_AUTH_SHAREDINFRA_TOKEN: changeitchangeitchangeitchangeitchangeitchangeitchangeitchangeit
CDS_SERVER_SECRETS_KEY: changeitchangeitchangeitchangeit
ports:
- "8081:8081"
- "8082:8082"
links:
- cds-db
- cds-cache

cds-ui:
image: ovhcom/cds-ui:latest
environment:
BACKEND_HOST: ${HOSTNAME}:8081
BASE_URL: /
ports:
- "2015:2015"
links:
- cds-api

cds-hatchery-swarm:
image: ovhcom/cds-hatchery:latest
command: /app/hatchery-linux-amd64 swarm
environment:
CDS_LOG_LEVEL: notice
CDS_RATIO_SERVICE: 50
CDS_TOKEN: changeitchangeitchangeitchangeitchangeitchangeitchangeitchangeit
DOCKER_HOST: tcp://${HOSTNAME}:2375
CDS_API: http://cds-api:8081
CDS_NAME: ${HOSTNAME}-swarm
CDS_MAX_WORKER: 2
CDS_MAX_CONTAINERS: 4
CDS_PROVISION: 0
CDS_REQUEST_API_TIMEOUT: 120
links:
- cds-api

cds-hatchery-local:
image: ovhcom/cds-hatchery:latest
command: /app/hatchery-linux-amd64 local
environment:
CDS_TOKEN: changeitchangeitchangeitchangeitchangeitchangeitchangeitchangeit
CDS_API: http://cds-api:8081
CDS_NAME: ${HOSTNAME}-local
links:
- cds-api

volumes:
cds-artefacts-volume:
driver: local
3 changes: 1 addition & 2 deletions ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ RUN apt-get update && \
LAST_RELEASE=$(curl -s https://api.github.com/repos/ovh/cds/releases | grep tag_name | head -n 1 | cut -d '"' -f 4) && \
curl -s https://api.github.com/repos/ovh/cds/releases | grep ${LAST_RELEASE} | grep browser_download_url | grep 'ui.tar.gz' | cut -d '"' -f 4 | xargs wget && \
tar xzf ui.tar.gz && mv dist/* . && \
wget https://caddyserver.com/download/linux/amd64 && mv amd64 caddy.tar.gz && \
tar xzf caddy.tar.gz && \
wget https://github.com/ovh/cds/releases/download/0.8.0/caddy-linux-amd64 && mv caddy-linux-amd64 caddy && \
chmod +rx caddy setup && \
chown -R nobody:nogroup /app && \
rm -rf /var/lib/apt/lists/*
Expand Down

0 comments on commit 8b75f90

Please sign in to comment.