Skip to content

Commit 8b75f90

Browse files
yesnaultfsamin
authored andcommitted
chore (*): docker-compose (#579)
* chore: docker-compose file Signed-off-by: Yvonnick Esnault <[email protected]> * doc: title Signed-off-by: Yvonnick Esnault <[email protected]> * Update run-with-docker-compose.md * chore: use caddy built from master Signed-off-by: Yvonnick Esnault <[email protected]>
1 parent 27d62c1 commit 8b75f90

File tree

4 files changed

+191
-10
lines changed

4 files changed

+191
-10
lines changed

doc/overview/introduction.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
## What is CDS?
22

33
CDS is a Continuous Delivery solution with an architecture featuring:
4-
4+
55
* A complete isolation between tenants
66
* High availability oriented architecture
77
* Automatic scaling
88
* Automation oriented with iso-feature API, CLI and WebUI
99

10-
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).
10+
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).
1111

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

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

36-
### Deployment
36+
### Deployment
3737

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

5959
### Action requirements and worker capabilities
6060

61-
CDS is built on simples principes:
61+
CDS is built on simples principles:
6262

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

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

69-
70-
Relation between workers and actions.
71-
68+
Relation between workers and actions.
7269

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

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

9491
## Next Steps
9592

93+
* [Run with Docker-Compose](/doc/tutorials/run-with-docker-compose.md)
9694
* [Quick start](/doc/overview/quickstart.md)
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
## Run with Docker-Compose
2+
3+
The [docker-compose.yml](/docker-compose.yml) contains:
4+
- cds-db service with a postgresql
5+
- cds-cache service with a redis
6+
- cds-migrate service to prepare DB tables.
7+
- cds-api service
8+
- cds-ui service
9+
- cds-hatchery-swarm service
10+
- cds-hatchery-local service
11+
12+
Docker compose is very convenient to launch CDS for testing it. But this is not recommended for a Production Installation.
13+
14+
## How to run
15+
16+
```bash
17+
$ git clone https://github.com/ovh/cds.git
18+
cd cds
19+
export HOSTNAME=$(hostname)
20+
21+
# Create PG Database
22+
docker-compose up --no-recreate -d cds-db
23+
24+
# check if db is UP
25+
# check if last log is "LOG: database system is ready to accept connections"
26+
docker-compose logs
27+
28+
docker-compose up --no-recreate cds-migrate
29+
# You should have this log: "cds_cds-migrate_1 exited with code 0"
30+
31+
# run last API and UI
32+
docker-compose up cds-api cds-ui
33+
34+
```
35+
36+
Open a browser on http://localhost:2015, then register a new user.
37+
As there is no SMTP server configured in docker-compose.yml file,
38+
run `docker-compose logs` to get URL for validate the registration.
39+
40+
## Prepare Project, Pipeline and Application
41+
42+
On UI:
43+
44+
- Create a project
45+
- Create an application, with an void pipeline
46+
- Create a pipeline, with a stage and a job
47+
- Inside job, add a step of type "script"
48+
- In script content, add theses lines:
49+
```bash
50+
#!/bin/bash
51+
set -ex
52+
echo "foo"
53+
sleep 10
54+
echo "bar"
55+
```
56+
57+
## Run Pipeline
58+
59+
Run pipeline. As you can see now, you pipeline is in "waiting status". You have
60+
to run a CDS Worker or a CDS Hatchery which aims to create workers.
61+
62+
Let's run an hatchery with docker-compose. Two ways:
63+
- a containers with a hatchery `local`. Workers will be spawn inside this container.
64+
- a containers with a hatchery `swarm`. Each worker will be in their own container.
65+
66+
If your host expose docker API, you can run `docker-compose up cds-hatchery-swarm`
67+
68+
Otherwise, you can run `docker-compose up cds-hatchery-local`
69+
70+
*Running a hatchery "local" in a container is not recommanded. Use this way only for test purpose*.
71+
72+
After running a Hatchery, your pipeline will be in "Building" status, then "Success" status.

docker-compose.yml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
version: '3'
2+
3+
services:
4+
cds-db:
5+
image: postgres:9.6.2
6+
environment:
7+
POSTGRES_PASSWORD: cds
8+
POSTGRES_USER: cds
9+
10+
cds-cache:
11+
image: redis:alpine
12+
command: redis-server --requirepass cds
13+
ports:
14+
- "6379:6379"
15+
16+
cds-migrate:
17+
image: ovhcom/cds-api:latest
18+
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
19+
links:
20+
- cds-db
21+
22+
cds-api:
23+
image: ovhcom/cds-api:latest
24+
command: /app/api-linux-amd64
25+
volumes:
26+
- cds-artefacts-volume:/app/artefacts
27+
environment:
28+
CDS_VCS_REPOSITORIES_GITHUB_STATUSES_URL_DISABLED: "true"
29+
CDS_VCS_REPOSITORIES_GITHUB_STATUSES_DISABLED: "true"
30+
CDS_VCS_REPOSITORIES_CACHERLOADER_DISABLED: "true"
31+
CDS_VCS_REPOSITORIES_BITBUCKET_STATUSES_DISABLED: "true"
32+
CDS_DB_HOST: cds-db
33+
CDS_DB_PASSWORD: cds
34+
CDS_DB_TIMEOUT: 10000
35+
CDS_DB_USER: cds
36+
CDS_DB_NAME: cds
37+
CDS_DB_MAXCONN: 40
38+
CDS_DB_PORT: 5432
39+
CDS_DB_SSLMODE: disable
40+
CDS_URL_API: ${HOSTNAME}:8081
41+
CDS_URL_UI: ${HOSTNAME}:8080
42+
CDS_SMTP_DISABLE: "true"
43+
CDS_SMTP_TLS: "false"
44+
CDS_SMTP_FROM: [email protected]
45+
CDS_SMTP_HOST: smtp.foo.cds
46+
CDS_SMTP_PORT: 25
47+
CDS_AUTH_LOCALMODE: session
48+
CDS_AUTH_LDAP_ENABLE: "false"
49+
CDS_AUTH_DEFAULTGROUP: cdsdemo
50+
CDS_LOG_LEVEL: info
51+
CDS_SERVER_HTTP_SESSIONTTL: 600
52+
CDS_CACHE_TTL: 60
53+
CDS_CACHE_REDIS_HOST: cds-cache:6379
54+
CDS_CACHE_REDIS_PASSWORD: cds
55+
CDS_CACHE_MODE: redis
56+
CDS_DIRECTORIES_DOWNLOAD: /app
57+
CDS_VCS_POLLING_DISABLED: "false"
58+
CDS_SERVER_HTTP_PORT: 8081
59+
CDS_SERVER_GRPC_PORT: 8082
60+
CDS_SCHEDULERS_DISABLED: "false"
61+
CDS_DIRECTORIES_KEYS: /app/keys
62+
CDS_ARTIFACT_MODE: local
63+
CDS_ARTIFACT_LOCAL_BASEDIR: /app/artefacts
64+
CDS_AUTH_SHAREDINFRA_TOKEN: changeitchangeitchangeitchangeitchangeitchangeitchangeitchangeit
65+
CDS_SERVER_SECRETS_KEY: changeitchangeitchangeitchangeit
66+
ports:
67+
- "8081:8081"
68+
- "8082:8082"
69+
links:
70+
- cds-db
71+
- cds-cache
72+
73+
cds-ui:
74+
image: ovhcom/cds-ui:latest
75+
environment:
76+
BACKEND_HOST: ${HOSTNAME}:8081
77+
BASE_URL: /
78+
ports:
79+
- "2015:2015"
80+
links:
81+
- cds-api
82+
83+
cds-hatchery-swarm:
84+
image: ovhcom/cds-hatchery:latest
85+
command: /app/hatchery-linux-amd64 swarm
86+
environment:
87+
CDS_LOG_LEVEL: notice
88+
CDS_RATIO_SERVICE: 50
89+
CDS_TOKEN: changeitchangeitchangeitchangeitchangeitchangeitchangeitchangeit
90+
DOCKER_HOST: tcp://${HOSTNAME}:2375
91+
CDS_API: http://cds-api:8081
92+
CDS_NAME: ${HOSTNAME}-swarm
93+
CDS_MAX_WORKER: 2
94+
CDS_MAX_CONTAINERS: 4
95+
CDS_PROVISION: 0
96+
CDS_REQUEST_API_TIMEOUT: 120
97+
links:
98+
- cds-api
99+
100+
cds-hatchery-local:
101+
image: ovhcom/cds-hatchery:latest
102+
command: /app/hatchery-linux-amd64 local
103+
environment:
104+
CDS_TOKEN: changeitchangeitchangeitchangeitchangeitchangeitchangeitchangeit
105+
CDS_API: http://cds-api:8081
106+
CDS_NAME: ${HOSTNAME}-local
107+
links:
108+
- cds-api
109+
110+
volumes:
111+
cds-artefacts-volume:
112+
driver: local

ui/Dockerfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ RUN apt-get update && \
55
LAST_RELEASE=$(curl -s https://api.github.com/repos/ovh/cds/releases | grep tag_name | head -n 1 | cut -d '"' -f 4) && \
66
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 && \
77
tar xzf ui.tar.gz && mv dist/* . && \
8-
wget https://caddyserver.com/download/linux/amd64 && mv amd64 caddy.tar.gz && \
9-
tar xzf caddy.tar.gz && \
8+
wget https://github.com/ovh/cds/releases/download/0.8.0/caddy-linux-amd64 && mv caddy-linux-amd64 caddy && \
109
chmod +rx caddy setup && \
1110
chown -R nobody:nogroup /app && \
1211
rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)