Skip to main content
There are two ways to define environment variables, in the env field in your App Configuration and with Secrets. Once the env variables and secrets are set up and defined in your compose.yaml, they’ll show up at runtime in your env context property. For local development, all files in your gitignored .env file will also show up as secrets if you reference them in your compose.yaml file.

Example

Configure your app with environment variables in your compose.yaml
# compose.yaml
name: "my-app"
env: 
  local:
    MY_VAR: "foo"
    ANOTHER_VAR: "bar"
  cloud:
    MY_VAR: "boo"
    ANOTHER_VAR: "baz"
secrets:
  - MY_SECRET
tasks:
 - name: "task1"
   path: "./task1.ts"
Reference those env variables in your tasks
/// <reference types="../../.compose/types.d.ts" /> 

export async function main(
  { env }: TaskContext,
  _args: any
) {
  console.log(env.MY_VAR);
  console.log(env.ANOTHER_VAR);
  console.log(env.MY_SECRET);
}