Docker Compose
Run with Docker-Compose
The docker-compose.yml contains:
- cds-db service with a PostgreSQL
- cds-cache service with a Redis
- elasticsearch service with an Elasticsearch
- dockerhost allows cds-hatchery-swarm service to communicate with the local docker daemon
- cds-migrate service to prepare databases for API and CDN
- cds-api service
- cds-ui service
- cds-elasticsearch service
- cds-hatchery-swarm service
- cds-vcs service
- cds-repositories service
- cds-cdn service
Docker compose is very convenient to launch CDS for testing it. But this is not recommended for a Production Installation.
How to run
Windows平臺(tái)下,請(qǐng)使用git-bash操作
$ mkdir /tmp/cdstest && cd /tmp/cdstest && mkdir -p tools/smtpmock
$ curl https://raw.githubusercontent.com/ovh/cds/0.48.1/docker-compose.yml -o docker-compose.yml
# hostname需要注意一下,如需修改陆盘,請(qǐng)修改*HOSTNAME*變量,其他地方有用到
$ export HOSTNAME=$(hostname)
$ export CDS_DOCKER_IMAGE=ovhcom/cds-engine:0.48.1
# Get the latest version
$ docker pull ovhcom/cds-engine:0.48.1
# Create PostgreSQL database, redis and elasticsearch
$ docker-compose up --no-recreate -d cds-db cds-cache elasticsearch dockerhost
# check if database is up, the logs must contain "LOG: database system is ready to accept connections"
$ docker-compose logs| grep 'database system is ready to accept connections'
# you should have this line after few seconds: cds-db_1 | LOG: database system is ready to accept connections
$ docker-compose up --no-recreate cds-db-init
$ docker-compose up --no-recreate cds-migrate
# You should have this log: "cdstest_cds-migrate_1 exited with code 0"
# prepare initial configuration.
$ docker-compose up cds-prepare
# disable the smtp server
$ export CDS_EDIT_CONFIG="api.smtp.disable=true"
$ docker-compose up cds-edit-config
# run API
$ docker-compose up -d cds-api
# the INIT_TOKEN variable will be used by cdsctl to create first admin user
$ TOKEN_CMD=$(docker logs cdstest_cds-prepare_1|grep TOKEN) && $TOKEN_CMD
# if you have this error: "command too long: export INIT_TOKEN=....",
# you can manually execute the command "export INIT_TOKEN=...."
# docker logs應(yīng)該獲取不到日志的了,自己復(fù)制"export INIT_TOKEN=...."那段執(zhí)行就好
# 以下執(zhí)行cdsctl命令都需要有*INIT_TOKEN*變量支持
# create user
$ curl 'http://localhost:8081/download/cdsctl/linux/amd64?variant=nokeychain' -o cdsctl
# on OSX: $ curl 'http://localhost:8081/download/cdsctl/darwin/amd64?variant=nokeychain' -o cdsctl
# windows: $ curl 'http://localhost:8081/download/cdsctl/windows/amd64?variant=nokeychain' -o cdsctl.exe
$ chmod +x cdsctl
$ ./cdsctl signup --api-url http://localhost:8081 --email admin@localhost.local --username admin --fullname admin
# enter a strong password
# verify the user
$ VERIFY_CMD=$(docker-compose logs cds-api|grep 'cdsctl signup verify'|cut -d '$' -f2|xargs) && ./$VERIFY_CMD
# if you have this error: "such file or directory: ./cdsctl signup verify --api-url...",
# you can manually execute the command "./cdsctl signup verify --api-url..."
# run cdsctl
$ ./cdsctl user me
# should returns something like:
#./cdsctl user me
#created 2019-12-18 14:25:53.089718 +0000 UTC
#fullname admin
#id vvvvv-dddd-eeee-dddd-fffffffff
#ring ADMIN
#username admin
# run others services
$ docker-compose up -d cds-ui cds-cdn cds-hooks cds-elasticsearch cds-hatchery-swarm
# create first worker model
$ ./cdsctl worker model import https://raw.githubusercontent.com/ovh/cds/0.48.1/contrib/worker-models/go-official-1.13.yml
# import Import a workflow template
$ ./cdsctl template push https://raw.githubusercontent.com/ovh/cds/0.48.1/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 !
# create project, then create a workflow from template
$ ./cdsctl project create DEMO FirstProject
$ ./cdsctl template apply DEMO MyFirstWorkflow shared.infra/demo-workflow-hello-world --force --import-push --quiet
# run CDS Workflow!
$ ./cdsctl workflow run DEMO MyFirstWorkflow
Workflow MyFirstWorkflow #1 has been launched
http://localhost:8080/project/DEMO/workflow/MyFirstWorkflow/run/1
- Login on WebUI
Open a browser on http://localhost:8080/account/signup, then login with the user admin
,
- Check on UI
on http://localhost:8080/project/DEMO/workflow/MyFirstWorkflow/run/1 you will have
You see that the pipeline deploy in production was not launched automatically. There is a Run Condition on it cds.manual = true
:
The build pipeline contains two stages, with only one job in each stage
Setup connection with a VCS
# READ THE section https://ovh.github.io/cds/docs/integrations/github/github_repository_manager/#create-a-cds-application-on-github to generate the clientId and clientSecret.
# Short version:
# go on https://github.com/settings/applications/new
# Application name: cds-test-docker-compose
# Homepage URL: http://localhost:8080
# Authorization callback: http://localhost:8080/cdsapi/repositories_manager/oauth2/callback
# send click on register application.
$ export CDS_EDIT_CONFIG="vcs.servers.github.github.clientId=xxxxx vcs.servers.github.github.clientSecret=xxxxx "
$ docker-compose up cds-edit-config
$ docker-compose up -d cds-vcs cds-repositories
Notice that here, you have the VCS and Repositories services up and running.
vcs: The aim of this μService is to communicate with Repository Manager as GitHub, GitLab, Bitbucket… But, as your CDS is not probably public, GitHub won’t be able to call your CDS to automatically run your workflow on each git push.
repositories: this μService is used to enable the as-code feature. Users can store CDS Files on their repositories. This service clones user repositories on local filesystem.
Then, next with Actions, Plugins
- Import actions, example:
$ ./cdsctl action import https://raw.githubusercontent.com/ovh/cds/0.48.1/contrib/actions/cds-docker-package.yml
Go further
- How to use OpenStack infrastructure to spawn CDS Workers read more
- Link CDS to a repository manager, as GitHub, Bitbucket Server or GitLab
- Learn more about CDS variables read more