110 lines
2.9 KiB
Plaintext
110 lines
2.9 KiB
Plaintext
= Docker-Compose Template
|
|
|
|
.Provided Templates:
|
|
|===
|
|
|Name |Description
|
|
|.docker-compose-deploy | Executes docker compose against a remote machine.
|
|
|.docker-compose-validate | Validates the syntactic correctness of your compose files. Still can have execution problems.
|
|
|===
|
|
|
|
Copy files with scp from your repository onto the remote system.
|
|
Then executes `docker compose` over an SSH connection.
|
|
For this SSH connection you have to provide an SSH key under a CI-CD-Variable with the name $SSH_PRIVATE_KEY.
|
|
If you already have a different $SSH_PRIVATE_KEY you can overwrite the variable SSH_PRIVATE_KEY_DEPLOY.
|
|
|
|
To parametrise the docker-compose file you can use a .env file.
|
|
The .env file should not contain any secrets.
|
|
For this reason you can create a .env file dynamically.
|
|
To generate a .env file you can provide a script under the path ENV_SETUP_FILE.
|
|
|
|
.Example for a setup_env.sh
|
|
----
|
|
#!/bin/sh
|
|
|
|
# Prints all enviroments into the .env file.
|
|
printenv >> .env
|
|
|
|
# to set a different project prefix use this ENV
|
|
echo COMPOSE_PROJECT_NAME=project-prefix >>.env
|
|
|
|
# Secrets
|
|
# $SOME_PASSWORD is a variable within the gitlab CI variable
|
|
echo SOME_PASSWORD="$SOME_PASSWORD" >>.env
|
|
----
|
|
|
|
== SSH Problem workaround
|
|
|
|
Sometimes there is a problem with some SSH servers and docker.
|
|
We have a workaround for this, please override your script with the following:
|
|
|
|
----
|
|
script:
|
|
- !reference [.broken-ssh-connection-workaround, script]
|
|
----
|
|
|
|
.Variables
|
|
|===
|
|
|
|
|Name |Description | Default Value
|
|
| SSH_PRIVATE_KEY_DEPLOY
|
|
| Private key to access remote system.
|
|
| $SSH_PRIVATE_KEY (In den CI-CD variablen)
|
|
|
|
| SSH_URL
|
|
| URL of the remote server.
|
|
| -
|
|
|
|
| SSH_PORT
|
|
| SSH port of the remote server.
|
|
| 22
|
|
|
|
| SSH_USER
|
|
| The user that is used to log into the remote maschine.
|
|
| -
|
|
|
|
| DOCKER_REGISTRY
|
|
| The container registry that will be used to pull images.
|
|
| $CI_REGISTRY
|
|
|
|
| DOCKER_REGISTRY_PASS
|
|
| The passwort to the docker registry that should be used.
|
|
| $CI_REGISTRY_PASSWORD
|
|
|
|
| DOCKER_REGISTRY_USER
|
|
| The user to the docker registry that should be used.
|
|
| $CI_REGISTRY_USER
|
|
|
|
| ENV_SETUP_FILE
|
|
| If you want to use a .env file, this script can be used to create one.
|
|
Secrets should not be stored within your repository. Use the CI-CD variables in the gitlab setting page.
|
|
| setup_env.sh
|
|
|
|
| SCP_DESTINATION
|
|
| Target path for scp to push files to.
|
|
| -
|
|
|
|
| SCP_SOURCE
|
|
| Path you want to copy to the remote system.
|
|
| $CI_PROJECT_DIR
|
|
|
|
| COMPOSE_EXTRA_ARGS
|
|
| Additional arguments you want to send to docker compose.
|
|
For example multiple `-f compose.file.extra` definitions.
|
|
| -
|
|
|
|
| COMPOSE_UP_EXTRA_ARGS
|
|
| Additional arguments you want to send to docker compose up.
|
|
For example multiple `--no-deps --no-build` definitions.
|
|
| -
|
|
|
|
| DOCKER_COMPOSE_VERSION
|
|
| Version of `docker compose`.
|
|
| v2.7.0
|
|
|
|
| DOCKER_COMPOSE
|
|
| Local path to `docker compose`. If this file does not exist, the script will download it from github.
|
|
| $CI_PROJECT_DIR/docker-compose
|
|
|===
|
|
|
|
:template: IaC/docker-compose.gitlab-ci.yml
|
|
include::../../../template-printer.adoc[] |