summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-06-25 16:04:54 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-07-06 16:43:15 +0200
commita6ef87338365560bef7fedf1119c9f65bb8c621c (patch)
tree5f70458e3f090df8948f1e97ca3dd2c7e0c43620 /doc
parentff0b88b1a81a06b53a7d2e1a4e0dccabcb486ef7 (diff)
downloadgitlab-ci-a6ef87338365560bef7fedf1119c9f65bb8c621c.tar.gz
Added documentation about the use of Dpl
Diffstat (limited to 'doc')
-rw-r--r--doc/README.md1
-rw-r--r--doc/deployment/README.md97
-rw-r--r--doc/examples/README.md2
-rw-r--r--doc/examples/test-and-deploy-python-application-to-heroku.md68
-rw-r--r--doc/examples/test-and-deploy-ruby-application-to-heroku.md63
5 files changed, 231 insertions, 0 deletions
diff --git a/doc/README.md b/doc/README.md
index 8307276..c44ef03 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -6,6 +6,7 @@
+ [Update](update/README.md)
+ [Runners](runners/README.md)
+ [Builds Configuration](builds_configuration/README.md)
++ [Deployment](deployment/README.md)
+ [Permissions](permissions/README.md) User permissions
+ [Rake Tasks](raketasks/README.md) Backup and restore take tasks
+ [Migrating to packaged CI](migration_to_omnibus/README.md)
diff --git a/doc/deployment/README.md b/doc/deployment/README.md
new file mode 100644
index 0000000..137a519
--- /dev/null
+++ b/doc/deployment/README.md
@@ -0,0 +1,97 @@
+## GitLab-CI deployment
+
+GitLab-CI support deployment builds. Deploy Builds that are ran when all other builds have succeeded. This builds can be defined using simple syntax:
+
+```yaml
+production:
+ type: deploy
+ script:
+ - prepare-for-deploy
+ - deploy-to-service
+```
+
+## Use Travis-CI deployment tool
+We recommend to use **Dpl**. Dpl (dee-pee-ell) is a deploy tool made for continuous deployment that's developed and used by Travis CI, but can also be used with GitLab CI. You can read more information about it here: https://github.com/travis-ci/dpl.
+
+### Requirements
+To use `dpl` you need `ruby` at least 1.8.7 with ability to install `gems`.
+
+### Installation
+The `dpl` can be installed on any machine with:
+```
+gem install dpl
+```
+
+If you don't have Ruby installed you can do it on `Debian-compatible` `Linux` with:
+```
+apt-get update
+apt-get install ruby-dev
+```
+
+What is also nice about `Dpl` is that you can install it on your computer and test all the commands from your Terminal without the need to test it on `CI` server.
+
+### How to use it?
+The `dpl` provides support for vast number of services, including: Heroku, Cloud Foundry, AWS/S3, and more. To use it simply define provider and any additional parameters required by the provider.
+
+For example if you want to use it to deploy your application to heroku, you need to specify `heroku` as provider, specify `api-key` and `app`. There's more and all possible parameters can be found here: https://github.com/travis-ci/dpl#heroku
+
+```
+staging:
+ type: deploy
+ - gem install dpl
+ - dpl --provider=heroku --app=my-app-staging --api-key=$HEROKU_STAGING_API_KEY
+```
+
+In the above example we use `dpl` to deploy `my-app-staging` to Heroku server with api-key stored in `HEROKU_STAGING_API_KEY` secure variable.
+
+### Use different provider
+Tu use different provider take a look at long list of [Supported Providers](https://github.com/travis-ci/dpl#supported-providers).
+
+### How to use it to have staging and production environment?
+It's pretty common in developer workflow to have staging (-dev) and production environment. If we consider above example: we would like to deploy `master` branch to `staging` and `all tags` to `production environment`. The final `.gitlab-ci.yml` for such setup would look like this:
+
+```
+staging:
+ type: deploy
+ - gem install dpl
+ - dpl --provider=heroku --app=my-app-staging --api-key=$HEROKU_STAGING_API_KEY
+ only:
+ - master
+
+production:
+ type: deploy
+ - gem install dpl
+ - dpl --provider=heroku --app=my-app-production --api-key=$HEROKU_PRODUCTION_API_KEY
+ only:
+ - tags
+```
+
+We basically created two deploy jobs that are execute for different events:
+1. `staging` is executed for all commits that were pushed to `master` branch,
+2. `production` is executed for all pushed tags.
+
+We also use two secure variables:
+1. `HEROKU_STAGING_API_KEY` - Heroku API key used to deploy staging app,
+2. `HEROKU_PRODUCTION_API_KEY` - Heroku API key used to deploy production app.
+
+### The way to store API keys?
+In GitLab CI 7.12 a new feature was introduced: Secure Variables. Secure Variables can added by going to `Project > Variables > Add Variable`. **This feature requires `gitlab-runner` with version equal or greater than 0.4.0.** The variable defined in project settings are send with build script to runner and set before executing script. What is important that such variable is stored outside of the project's repository. You should never store secrets in your project's `.gitlab-ci.yml`! What is also important that it's value is hidden in the build log.
+
+You access added variable by prefixing it's name with `$` (on non-Windows runners) or `%` (for Windows Batch runners):
+1. `$SECRET_VARIABLE` - use it for non-Windows runners
+2. `%SECRET_VARIABLE%` - use it for Windows Batch runners
+
+### Using `dpl` with `Docker`
+When you use `runner` you most likely configured it to use your server's shell commands. This means that all commands are run in context of local user (ie. gitlab_runner or gitlab_ci_multi_runner). It also means that most probably in your `Docker` container you don't have the `Ruby` runtime. You have to install it:
+```
+staging:
+ type: deploy
+ - apt-get update -yq
+ - apt-get install -y ruby-dev
+ - gem install dpl
+ - dpl --provider=heroku --app=my-app-staging --api-key=$HEROKU_STAGING_API_KEY
+ only:
+ - master
+```
+
+The first line `apt-get update -yq` updates the list of available packages, where second `apt-get install -y ruby-dev` install `Ruby` runtime on system. The above example is valid for all Debian-compatible systems.
diff --git a/doc/examples/README.md b/doc/examples/README.md
index 444d68b..23e9740 100644
--- a/doc/examples/README.md
+++ b/doc/examples/README.md
@@ -35,6 +35,8 @@ CI_PROJECT_DIR
+ [Build script for Omniauth LDAP](build-script-for-omniauth-ldap.md)
+ [Build script GitLab CE](build_script_gitlab_ce.md)
+ [Build script for Sencha deploy PhoneGapBuild](build_script_sencha_deploy_phonegapbuild.md)
++ [Test and deploy Ruby Application to Heroku](test-and-deploy-ruby-application-to-heroku.md)
++ [Test and deploy Python Application to Heroku](test-and-deploy-python-application-to-heroku.md)
# Configuring runner examples
diff --git a/doc/examples/test-and-deploy-python-application-to-heroku.md b/doc/examples/test-and-deploy-python-application-to-heroku.md
new file mode 100644
index 0000000..0a9b9d7
--- /dev/null
+++ b/doc/examples/test-and-deploy-python-application-to-heroku.md
@@ -0,0 +1,68 @@
+### Test and Deploy Python application to Heroku
+Example Python application with tests on PostgreSQL database, staging and production deployment to Heroku can be found here:
+[source](https://gitlab.com/ayufan/python-getting-started) and here: [ci](https://ci.gitlab.com/projects/4080)
+
+### Configure project
+This is how the configuration (the `.gitlab-ci.yml`) for that project looks like:
+```yaml
+test:
+ script:
+ # this configures django application to use attached postgres database that is run on `postgres` host
+ - export DATABASE_URL=postgres://postgres:@postgres:5432/python-test-app
+ - apt-get update -qy
+ - apt-get install -y python-dev python-pip
+ - pip install -r requirements.txt
+ - python manage.py test
+
+staging:
+ type: deploy
+ script:
+ - apt-get update -qy
+ - apt-get install -y ruby-dev
+ - gem install dpl
+ - dpl --provider=heroku --app=gitlab-ci-python-test-staging --api-key=$HEROKU_STAGING_API_KEY
+ only:
+ - master
+
+production:
+ type: deploy
+ script:
+ - apt-get update -qy
+ - apt-get install -y ruby-dev
+ - gem install dpl
+ - dpl --provider=heroku --app=gitlab-ci-python-test-prod --api-key=$HEROKU_PRODUCTION_API_KEY
+ only:
+ - tags
+```
+
+This project have three jobs:
+1. `test` - used to test rails application,
+2. `staging` - used to automatically deploy staging environment every push to `master` branch
+3. `production` - used to automatically deploy production environmnet for every created tag
+
+### Store API keys
+The project requires to create two secure variables in `Project > Variables`:
+1. `HEROKU_STAGING_API_KEY` - Heroku API key used to deploy staging app,
+2. `HEROKU_PRODUCTION_API_KEY` - Heroku API key used to deploy production app.
+
+Heroku API key can be found in [Manage Account](https://dashboard.heroku.com/account).
+
+### Create Heroku application
+You have to navigate to Heroku [Dashboard](https://dashboard.heroku.com/) and create new application to each of your environments.
+
+### Create runner
+To build this project you also need to have `Runner`. You can use public runners available on `ci.gitlab.com`, but you can also provide your own:
+```
+gitlab-ci-multi-runner register \
+ --non-interactive \
+ --url "https://ci.gitlab.com/" \
+ --registration-token "PROJECT_REGISTRATION_TOKEN" \
+ --description "python-3.2" \
+ --executor "docker" \
+ --docker-image python:3.2 \
+ --docker-postgres latest
+```
+
+Above command creates runner that uses `docker` (you need to have Docker installed), uses [python:3.2](https://registry.hub.docker.com/u/library/python/) image and uses [postgres](https://registry.hub.docker.com/u/library/postgres/) database.
+
+To access PostgreSQL database you need to connect to `host: postgres` instead of default: `localhost` as `postgres` user without password.
diff --git a/doc/examples/test-and-deploy-ruby-application-to-heroku.md b/doc/examples/test-and-deploy-ruby-application-to-heroku.md
new file mode 100644
index 0000000..91d52d0
--- /dev/null
+++ b/doc/examples/test-and-deploy-ruby-application-to-heroku.md
@@ -0,0 +1,63 @@
+## Test and Deploy Ruby application to Heroku
+Example Ruby application with tests on PostgreSQL database, staging and production deployment to Heroku can be found here:
+[source](https://gitlab.com/ayufan/ruby-getting-started) and here: [ci](https://ci.gitlab.com/projects/4050)
+
+### Configure project
+This is how the configuration (the `.gitlab-ci.yml`) for that project looks like:
+```yaml
+test:
+ script:
+ - apt-get update -qy
+ - apt-get install -y nodejs
+ - bundle install --path /cache
+ - bundle exec rake db:create RAILS_ENV=test
+ - bundle exec rake test
+
+staging:
+ type: deploy
+ script:
+ - gem install dpl
+ - dpl --provider=heroku --app=gitlab-ci-ruby-test-staging --api-key=$HEROKU_STAGING_API_KEY
+ only:
+ - master
+
+production:
+ type: deploy
+ script:
+ - gem install dpl
+ - dpl --provider=heroku --app=gitlab-ci-ruby-test-prod --api-key=$HEROKU_PRODUCTION_API_KEY
+ only:
+ - tags
+```
+
+This project have three jobs:
+1. `test` - used to test rails application,
+2. `staging` - used to automatically deploy staging environment every push to `master` branch
+3. `production` - used to automatically deploy production environmnet for every created tag
+
+### Store API keys
+The project requires to create two secure variables in `Project > Variables`:
+1. `HEROKU_STAGING_API_KEY` - Heroku API key used to deploy staging app,
+2. `HEROKU_PRODUCTION_API_KEY` - Heroku API key used to deploy production app.
+
+Heroku API key can be found in [Manage Account](https://dashboard.heroku.com/account).
+
+### Create Heroku application
+You have to navigate to Heroku [Dashboard](https://dashboard.heroku.com/) and create new application to each of your environments.
+
+### Create runner
+To build this project you also need to have `Runner`. You can use public runners available on `ci.gitlab.com`, but you can also provide your own:
+```
+gitlab-ci-multi-runner register \
+ --non-interactive \
+ --url "https://ci.gitlab.com/" \
+ --registration-token "PROJECT_REGISTRATION_TOKEN" \
+ --description "ruby-2.1" \
+ --executor "docker" \
+ --docker-image ruby:2.1 \
+ --docker-postgres latest
+```
+
+Above command creates runner that uses `docker` (you need to have Docker installed), uses [ruby:2.1](https://registry.hub.docker.com/u/library/ruby/) image and uses [postgres](https://registry.hub.docker.com/u/library/postgres/) database.
+
+To access PostgreSQL database you need to connect to `host: postgres` instead of default: `localhost` as `postgres` user without password.