Skip to content

Support Environment Variables for Local Builds#10192

Merged
falahat merged 71 commits intomainfrom
zip_deploy_env_vars
Mar 27, 2026
Merged

Support Environment Variables for Local Builds#10192
falahat merged 71 commits intomainfrom
zip_deploy_env_vars

Conversation

@falahat
Copy link
Copy Markdown
Contributor

@falahat falahat commented Mar 26, 2026

Description

Adds support for Environment Variables (from apphosting.yaml files, for example) and AutoInit Env Vars for Local Builds.
This correctly splits Build vs Runtime env vars. It passes build env vars to the build process and passes runtime env vars to the control plane when creating the build. It injects the SDK AutoInit env vars into both.

Scenarios Tested

  • I created a local build backend with ABIU enabled and the nodejs22 runtime
  • I set set the localBuild flag to true in firebase.json:
{
  "apphosting": {
    "backendId": "local-build",
    "rootDir": "/",
    "localBuild": true,
    "ignore": [
      "node_modules",
      ".git",
      "firebase-debug.log",
      "firebase-debug.*.log",
      "functions"
    ]
  }
}
  • I ran firebase deploy
  • I verified the app was built locally and deployed as expected

Sample Commands

annajowang and others added 30 commits November 22, 2025 01:29
1. Fix for injecting auto-init variables into the build

2. Fixes how we handle dependencies, nodejs paths, modulepaths, etc. This needs closer attention/fixes.

3. Adds env var handling (not secrets) and determines which env vars to pass down to the build
… variants) and include them in the final artifact
…ctually a local build (instead of assuming true.)
…ore strictly. We also remove some hardcoded values and we generalize the code so that it does not affect source deploys.

The goal is to prepare this PR so that we can safely submit it to main (behind the experiment flag.)
…ive. Only run it if it's a local build and the local build experiment flag is enabled.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces logic to split environment variables into build and runtime categories and injects Firebase configuration (autoinit variables) into the local build process for App Hosting backends. Key changes include the addition of the splitEnvVars utility, updates to localBuild to handle process environment injection and restoration, and logic in the prepare phase to fetch and merge web app configurations. I have no feedback to provide as the existing review comment was purely evaluative and did not point out an issue or improvement opportunity.

Comment thread src/deploy/apphosting/release.ts Outdated
@falahat
Copy link
Copy Markdown
Contributor Author

falahat commented Mar 27, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces functionality to split environment variables into build and runtime categories and injects Firebase SDK auto-init variables during local builds. Feedback focuses on improving the robustness of error handling when loading configurations and refining type definitions for environment variable values to avoid unnecessary type assertions in tests.

Comment thread src/apphosting/config.ts
Comment thread src/deploy/apphosting/prepare.ts Outdated
@falahat falahat requested review from Yuangwang and annajowang March 27, 2026 19:38
@falahat falahat marked this pull request as ready for review March 27, 2026 19:46
@falahat
Copy link
Copy Markdown
Contributor Author

falahat commented Mar 27, 2026

I have verified this one last time after our fixes.

@falahat falahat merged commit c84a521 into main Mar 27, 2026
57 of 60 checks passed
@falahat falahat deleted the zip_deploy_env_vars branch March 27, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants