Usa función para evitar repetición de código al definir variables.
Acorta nombre de variable usada para reemplazo de espacios.
Documenta nuevas variables, añade ejemplo de uso y retoca detalles.
@@ -6,35 +6,45 @@ Docker deployment utilities for REDMIC infrastructure. You can use it to deploy
***deploy**: Perform a deployment of a service on a remote Docker environment. Contains 3 stages:
**prepare-deploy*: Copy resources to remote environment (*docker-compose* files, service configurations, ...), prepare environment variables and directories, etc.
**prepare-deploy*: Copy resources to remote environment (*docker-compose* files, service configurations...), prepare environment variables and directories, etc.
**do-deploy*: Launch service on Docker environment. Both standard and Swarm modes are supported on remote Docker environment, but Swarm mode is recommended (even for a single-node clusters).
**do-deploy*: Launch service on Docker environment. Both standard (using docker-compose) and Swarm modes are supported on remote Docker environment, but Swarm mode is recommended (even for a single-node clusters).
**check-deploy*: Once deployment is done, this stage wait a defined period of time for the service to being up and running (or stopped after run successfully). If service status remains stable after several checks, then it is considered successfully deployed.
***create-nets**: Prepare remote environment creating Docker networks which are external to service (not created by service deployment itself).
***relaunch**: Force a previously deployed service to update, relaunching it with the same service configuration.
***relaunch**: Force a previously deployed service to update, relaunching it with the same service configuration. Available only for Swarm mode.
## Usage
For REDMIC, we use this image from GitLabCI configuration, but you can use it directly like:
For REDMIC, we use this image automatically from jobs defined in GitLabCI configuration, but you can run it directly:
As you can see, there is configuration through environment variables and by action script parameters. By environment variables, you configure the behaviour of this image itself. The script parameters are used like environment variables, but in the remote environment (where you are deploying to), in order to configure your service.
As you can see, there is configuration through environment variables and by script (<action>) parameters.
For environment variables, you may define these variables (**bold** are mandatory):
By environment variables, you can configure:
* Behaviour of this image itself.
* When action is *deploy* and using the `$ENV_PREFIX` in your variables, the remote environment (where you are deploying to) for service configuration.
By script parameters you can set:
* When action is *deploy*, remote environment variables, in order to configure your service. These parameters overwrite remote environment variables, including those defined using the `$ENV_PREFIX`.
* When action is *create-nets*, the name of the networks that are going to be created.
You may define these environment variables (**bold** are mandatory):
***STACK** / **SERVICE**: Name of Docker stack (Swarm mode) or service (standard mode) to deploy.
***SSH_REMOTE**: SSH user and host of remote machine where you are going to deploy.
***DEPLOY_KEY**: Private key paired with a public key accepted by remote machine, used to authenticate.
**COMPOSE_FILE*: Name of Docker Compose file with deployment definition. Multiple files are supported, separated by colon (`:`). Default `docker-compose.yml`.
**ENV_PREFIX*: Prefix used to identify variables to be defined in remote environment (without this prefix). Default `DD_`.
**ENV_SPACE_REPLACEMENT*: Unique string used to replace spaces into variable values while handling them. Default `<dd-space>`.
**COMPOSE_FILE*: Name of docker-compose file with deployment definition. Multiple files are supported, separated by colon (`:`). Default `docker-compose.yml`.
**DEPLOY_PATH*: Path in remote host where deployment directory (containing temporary files) will be created. Default `~`.
**DEPLOY_DIR_NAME*: Name of directory containing files needed for deployment. Default `deploy`.
**DEFAULT_DEPLOY_FILES*: Files needed for deployment, if `${DEPLOY_DIR_NAME}` does not exist. Default `docker-compose*.yml .env`.
@@ -49,4 +59,44 @@ For environment variables, you may define these variables (**bold** are mandator
**USE_IMAGE_DIGEST*: Update service image using digest data when relaunching. Default `0`.
**GREP_BIN*: Default `grep`.
Action may be one of `deploy.sh`, `create-nets.sh` or `relaunch.sh`, and parameters with variable/value depends on your service needs.