Skip to content
This repository was archived by the owner on Dec 17, 2023. It is now read-only.

Latest commit

 

History

History
executable file
·
133 lines (92 loc) · 3.69 KB

File metadata and controls

executable file
·
133 lines (92 loc) · 3.69 KB

🏠 > 🧠 Core Concepts

🔨 Task

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.

Task Types

There are two types of tasks:

Task Behavior

Dependencies

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:
      - startDatabaseServer

Please 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.

Extends

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: mysql

For more information about extending a task, please visit this document.

Shared Environments, Configs, and Inputs

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 start

For more information about sharing task resources, please visit the following documents:

Subtopics