Tasks are the most important component of your Zaruba project. It defines what you can do with application resources.
To run a task, you can invoke:
zaruba please <task-name>For more information about running a task, please visit this guide.
There are two types of tasks:
- simple command: Ended once completed (e.g.,
npm install, ordocker build). - long-running service: Keep running once completed. (e.g.,
docker start)
A task might have several dependencies. A task with dependencies cannot be started unless all its dependencies are completed.
For example, you cannot run a web server before running the database server. In that case, you can say that startWebServer depends on startDatabaseServer.
This is how you define the relation between startDatabaseServer and startWebServer:
tasks:
startDatabaseServer: {}
startWebServer:
dependencies:
- startDatabaseServerPlease note that you don't have to run the task's dependencies manually. Zaruba will always run the dependencies for you.
For more information about task dependencies, please visit this document.
A task might extend other task. Tasks that extend the same parent task are sharing the same behavior.
When you run a redis/mysql container, you are basically running a docker container. Aside from some specific configurations, the two tasks are having the same behavior.
In that case you can have startRedisContainer and startMysqlContainer sharing the same parent:
tasks:
startDockerContainer: {}
startRedisContainer:
extend: startDockerContainer
configs:
imageName: redis:latest
containerName: redis
startMysqlContainer:
extend: startMysqlContainer
configs:
imageName: mysql:latest
containerName: mysqlFor more information about extending a task, please visit this document.
Some tasks might share environments, configs, and inputs.
For example, when you run npm install and npm start, you have to share the same node version.
envs:
nvmEnv:
NODE_VERSION:
from: NVM_NODE_VERSION
default: 14
configs:
nvmConfig:
init: nvm use ${NODE_VERSION}
tasks:
npmInstall:
envRef: nvmEnv
configRef: nvmConfig
configs:
start: |
${ZARUBA_CONFIG_INIT} # this refer to `configs.nvmConfig.init`
npm install
npmStart:
envRef: nvmEnv
configRef: nvmConfig
configs:
start: |
${ZARUBA_CONFIG_INIT} # this refer to `configs.nvmConfig.init`
npm startFor more information about sharing task resources, please visit the following documents: