# Manage variables and environments > Set variables on an Orchard app, share values across an environment, store secrets, create environments, and pull variables to a local file. Source: https://docs.orchard.hackclub.com/run/environments/ Variables let you configure an app without rebuilding its image, so the same image can run with different settings in each [environment](/start/concepts/#environment). Set a variable on an app to configure that app. To reuse a value across apps, store it once as a shared variable in the environment and reference it from each app. ## Set app variables Saving variables restarts the app, because a process reads its environment at startup. **Dashboard** 1. Open the app. 2. Go to **Variables**. 3. Add the variables in **Editor**. To paste `.env` text, select **Raw**. 4. Select **Save**. **CLI** ```sh orchard deploy env set LOG_LEVEL=info ``` To store a value as a secret, add `--secret`. To read pairs from a file, use `--file`. An app can have up to 1,000 variables, and each value can be up to 64 KB. For files, use [storage](/deploy/storage/). For data, use a [database](/data/databases/). ## Shared variables A shared variable belongs to an environment. An app receives a shared value only when one of its own variables references it. ### Add a shared variable **Dashboard** 1. Open the project. 2. Go to **Variables**. 3. Select the environment. 4. In **Shared variables**, select **Add variable**. 5. Enter the key and the value. 6. Select **Save**. **CLI** ```sh orchard env vars set API_BASE_URL=https://api.example.com ``` ### Reference a shared variable Set an app variable to a reference: ```text API_BASE_URL=${{shared.API_BASE_URL}} ``` Orchard resolves references when it starts the pod and when it builds the image. If you change a shared value, Orchard updates and restarts only the apps whose values change. ## Secrets Orchard encrypts secret values at rest. You can replace a secret value, but you cannot read it back from the dashboard, the CLI, the API, or MCP. Orchard passes a secret to the container through the app's Kubernetes Secret. The pod spec holds a reference and not the value. ## Reference a database or another app To read a value from a database or another app, use a reference such as `${{resource.appdb.connection_string}}`. To add one, select **Use a resource** in the value field. The available fields are listed in [Connect an app to a database or app](/deploy/connect-resources/#available-fields). ## Create an environment Each project has a `Production` environment by default. Each new environment gets its own namespace. **Dashboard** 1. Open the project. 2. Open the environment menu. 3. Select **New environment**. 4. Enter a name. **CLI** ```sh orchard env create --name staging ``` > **Caution** > > Deleting an environment permanently deletes its namespace and everything in it. You cannot undo this action. ## Pull variables to a local file To match a cluster environment during local development, pull its variables: ```sh orchard env pull staging ``` The command writes the environment's shared variables to `.env.orchard`. To change the path, use `--out`. To merge one app's variables on top, use `--deployment `. Secret values are write-only, so the file contains commented placeholders for them. Fill these in locally. ## Related resources - [`orchard env` reference](/reference/cli/#env) - Every `orchard env` command and flag, including `orchard env pull`. - [Attach an Orchard project](/greenhouse/projects/) - Load an environment's variables into a Greenhouse machine. - [Manage a project](/teams/projects/) - Create, share, transfer, move, and delete projects.