This project implements a GitLab CI/CD template to deploy your application with [Docker Compose](https://docs.docker.com/compose/).
This project implements a GitLab CI/CD template to deploy your application with [Docker Compose](https://docs.docker.com/compose/) or [Docker Swarm](https://docs.docker.com/engine/swarm/).
## Usage
...
...
@@ -50,7 +50,7 @@ This chapter introduces key notions and principle to understand how this templat
### Managed deployment environments
This template implements continuous delivery/continuous deployment for projects hosted on Docker Compose.
This template implements continuous delivery/continuous deployment for projects hosted on Docker Compose or Docker Swarm.
It allows you to manage automatic deployment & cleanup of standard predefined environments.
Each environment can be enabled/disabled by configuration.
...
...
@@ -107,7 +107,7 @@ that you might use in your hook scripts or [Docker Compose files](https://docs.d
*`${environment_type}`: the current deployment environment type (`review`, `integration`, `staging` or `production`)
*`${environment_name}`: a generated application name to use for the current deployment environment (ex: `myapp-review-fix-bug-12` or `myapp-staging`) - _details below_
> :information_source: the `${environment_name}` is used by the Docker Compose template as the [Docker Compose project name](https://docs.docker.com/compose/project-name/).
> :information_source: the `${environment_name}` is used by the Docker Compose template as the [Docker Compose project name](https://docs.docker.com/compose/project-name/) or Docker Stack project name.
#### Generated environment name
...
...
@@ -204,12 +204,17 @@ and implement the following [dotenv files](https://docs.docker.com/compose/envir
1. a `.env` file defining defaults for all environments,
2. a `${environment_type}.env` file that might redefine or override defaults for a specific environment (e.g. `staging.env`).
#### Docker Swarm
Setting the `DCMP_CMD` variable to `docker stack` allows targetting a cluster hence multiple hosts to deploy your containers. It uses the same configuration and dotenv files lookup strategy as the classic Docker Compose workflow.
#### Deployment
The **deployment** is processed as follows by the template:
1. _optionally_ executes the `pre-compose-up.sh` script found in your project to perform pre-deployment stuff (for e.g. create required services),
2. runs [`docker-compose up`](https://docs.docker.com/reference/cli/docker/compose/up/) or [`docker stack deploy`](https://docs.docker.com/reference/cli/docker/stack/deploy/) based on the `DCMP_CMD` variable,
3. _optionally_ executes the `post-compose-up.sh` script found in your project to perform post-deployment stuff,
> :information_source: Important:
...
...
@@ -222,7 +227,7 @@ The **deployment** is processed as follows by the template:
The **cleanup** is processed as follows by the template:
1. _optionally_ executes the `pre-compose-down.sh` script found in your project to perform pre-cleanup stuff,
2. runs [`docker-compose down`](https://docs.docker.com/reference/cli/docker/compose/down/) or [`docker stack rm`](https://docs.docker.com/reference/cli/docker/stack/rm/) based on the `DCMP_CMD` variable,
3. _optionally_ executes the `post-compose-down.sh` script found in your project to perform post-cleanup stuff,
> :information_source: Important:
...
...
@@ -312,13 +317,14 @@ The Docker Compose template uses some global configuration used throughout all j
| Input / Variable | Description | Default value |
| `up-opts` / `DCMP_UP_OPTS` | [`compose up` options](https://docs.docker.com/reference/cli/docker/compose/up/#options) (only when using Docker Compose) | `--no-build --remove-orphans --wait --wait-timeout 180` |
| `down-opts`/ `DCMP_DOWN_OPTS` | [`compose down` options](https://docs.docker.com/reference/cli/docker/compose/down/#options) (only when using Docker Compose) | `--volumes --remove-orphans --rmi all` |
| `stack-deploy-opts` / `DCMP_STACK_DEPLOY_OPTS` | [`stack deploy` options](https://docs.docker.com/reference/cli/docker/stack/deploy/) (only when using Docker Stack) | `--prune` |
| :lock: `DCMP_SSH_PRIVATE_KEY` | Default SSH key to use when connecting to Docker hosts over SSH (can be overridden per env) | _none_ |
| `ssh-known-hosts` / `DCMP_SSH_KNOWN_HOSTS` | SSH `known_hosts` (file or text variable) | _none_ |
...
...
@@ -388,7 +394,7 @@ Here are variables supported to configure the production environment:
### Compose Config job
The Docker Compose template enables running [Compose Config](https://docs.docker.com/reference/cli/docker/compose/config/), thus enabling detection of syntax errors in your Compose or dotenv files.
The Docker Compose template enables running [Compose Config](https://docs.docker.com/reference/cli/docker/compose/config/) or [Stack Config](https://docs.docker.com/reference/cli/docker/stack/config/) based on `$DCMP_CMD`, thus enabling detection of syntax errors in your Compose, dotenv or Stack files.
This job is mapped to the `package-test` stage and is **active** by default.