Skip to content

Environment Variables

How to configure and manage environment variables for your deployments

Environment variables are configuration values that your application uses at runtime. Sproobo makes it easy to manage environment variables securely.

What are Environment Variables?

Environment variables are key-value pairs that:

  • Configure your application without code changes
  • Keep sensitive data like API keys and passwords secure
  • Allow different configurations for different environments
  • Are injected into your containers at runtime

Common Use Cases

  • Database connection strings
  • API keys and secrets
  • Feature flags
  • Service URLs
  • Environment names (production, staging, etc.)

Adding Environment Variables

  1. 1

    Navigate to Environment Variables

    Go to your Deployment → Settings → Environment Variables.
    Sproobo environment variables page
    Navigate to Environment Variables in your deployment settings.
  2. 2

    Add Variable

    Click "Add Variable" and enter:
    • Key: Variable name (e.g., DATABASE_URL)
    • Value: Variable value
    • Type: Regular or Secret
    Sproobo add environment variable form
    Add a new environment variable with key and value.
  3. 3

    Save Variable

    Click "Save" to add the variable. It will be available after the next deployment.
    ℹ️

    Environment variable changes require a redeploy to take effect.

Secret Variables

Secret variables are encrypted and never exposed in logs or UI:

  1. 1

    Mark as Secret

    When adding a variable, toggle "Secret" to encrypt it.
    Sproobo secret variable toggle
    Mark sensitive variables as Secret to encrypt them.
  2. 2

    Secret Variable Behavior

    Secret variables:
    • Are encrypted at rest using AES-256
    • Never shown in logs or UI (displayed as ***)
    • Only decrypted when injected into containers
    • Can't be retrieved after creation (must be reset to change)

    Important: Store your secret value in a password manager before saving, as you won't be able to view it again.

Bulk Import/Export

Manage multiple variables at once:

  1. 1

    Export Variables

    Click "Export" to download all variables as a .env file.
    Sproobo export environment variables
    Export all environment variables to a .env file.
  2. 2

    Import Variables

    Click "Import" to upload a .env file with multiple variables.
    env

    DATABASE_URL=postgresql://user:pass@host:5432/dbname API_KEY=your-api-key-here SECRET_KEY=your-secret-key-here

    Sproobo import environment variables
    Import multiple variables from a .env file.

Environment-Specific Variables

Different environments can have different values:

Environment Strategy

  • Project-level: Shared across all deployments in a project
  • Deployment-level: Specific to a single deployment
  • Environment Groups: Apply to multiple deployments at once

Variable Precedence

When variables are defined at multiple levels, the order of precedence is:

  1. Deployment-level variables (highest priority)
  2. Project-level variables
  3. Template defaults (lowest priority)
Sproobo environment variable precedence
Deployment variables override project variables, which override template defaults.

Using Variables in Dockerfiles

Reference environment variables in your Dockerfiles:

Dockerfiledockerfile

FROM node:20-alpine

Set build-time variable

ARG NODE_ENV=production ENV NODE_ENV=$NODE_ENV

Use runtime variable (injected by Sproobo)

ENV PORT=3000

WORKDIR /app COPY . . RUN npm install CMD ["npm", "start"]

Troubleshooting

Common issues with environment variables:

Common Issues

  • Variable not available: Make sure to redeploy after adding variables
  • Wrong value: Check for typos in variable names
  • Missing variable: Verify the variable is set at the correct level
  • Encoding issues: Ensure special characters are properly escaped

Best Practices

Best Practices

  • Use descriptive variable names (e.g., DATABASE_URL, not DB)
  • Store all secrets as Secret variables
  • Document what each variable does in your README
  • Use environment-specific values for different deployments
  • Rotate secrets regularly (every 90 days recommended)
  • Never commit secrets to version control

Next Steps

Now that you've configured environment variables: