Skip to content

Barebones implementation of local builds#10101

Merged
falahat merged 60 commits intomainfrom
zip_deploy_barebones
Mar 23, 2026
Merged

Barebones implementation of local builds#10101
falahat merged 60 commits intomainfrom
zip_deploy_barebones

Conversation

@falahat
Copy link
Copy Markdown
Contributor

@falahat falahat commented Mar 14, 2026

Description

Adds some prototype code for building nextjs apps locally.

Scenarios Tested

  • I created a firebase.json for a test app with local builds enabled
{
  "apphosting": {
    "backendId": "local-build",
    "rootDir": "/",
    "localBuild": true,
    "ignore": [
      "node_modules",
      ".git",
      "firebase-debug.log",
      "firebase-debug.*.log",
      "functions"
    ]
  }
}
  • I enabled the apphostinglocalbuilds flag and tested a local deployment and it was successful. Env vars did not work (as expected) but I was otherwise able to visit the locally built / zip-deployed site.

  • I tested a source deploy app

  • I disabled the apphostinglocalbuilds flag and the CLI correctly failed my deployment with a clear error message.

Sample Commands

firebase deploy

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.
@falahat
Copy link
Copy Markdown
Contributor Author

falahat commented Mar 18, 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 barebones support for local builds in App Hosting, allowing the deployment of pre-built artifacts. Key changes include updating dependencies, adding a new createTarArchive utility for packaging local build outputs, and modifying the deployment and release processes to differentiate between source and local build deployments. New test cases have been added to cover the local build functionality and experiment flag enforcement. The documentation for localBuild and the main deployment function has also been improved.

@falahat
Copy link
Copy Markdown
Contributor Author

falahat commented Mar 19, 2026

I manually tested a local build and it was correctly deployed. Of course, env vars didn't work yet but I confirmed that:

  1. We didn't do a Cloud Build for this deployment
  2. The rollout (from CLI) was successful and I saw the new version/rollout on the Firebase Console
  3. I was able to use the deployed nextjs site

@falahat falahat marked this pull request as ready for review March 20, 2026 18:14
@falahat falahat requested a review from Yuangwang March 20, 2026 19:08
@falahat falahat enabled auto-merge (squash) March 23, 2026 17:57
@falahat falahat merged commit add80da into main Mar 23, 2026
46 of 47 checks passed
@falahat falahat deleted the zip_deploy_barebones branch March 23, 2026 18:09
andrewbrook pushed a commit that referenced this pull request Mar 25, 2026
* Zip deploy fixes

* use staging and specify uploading TAR

* Improve docs

* Allow reading of simple env vars (not secrets) and passing them down to the local build process

* Add some fixes for npm parsing issues

* Adding various local fixes/hacks to make local builds work. It includes:

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

* Follow-up fixes for ensuring we have account access for cloud storage buckets

* formatting fixes

* Get rid of env override

* Temporarily add a test app to easily test changes

* For local builds, explicitly check for apphosting.yaml files (and all variants) and include them in the final artifact

* Add hono to packages

* Get rid of test app

* Get rid of uniformBucketLevelAccess config which was not required

* Fix tarball unit test

* Make local builds less hardcoded by checking if the build config is actually a local build (instead of assuming true.)

* Add a new experiment flag to control local builds (apphostinglocalbuilds)

* Remove references to runtime flag

* Clean up the PR so that we gate by apphostinglocalbuilds experiment more 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.)

* Make the code for adding service account IAM permission more restrictive. Only run it if it's a local build and the local build experiment flag is enabled.

* remove es2020 dependency

* feat: barebones local build implementation

* Parser fixes

* Undo some unintended changes

* Undo some unintended changes

* Linter fixes

* Linter fixes

* improve unit tests

* update npm shrinkwrap

* Update the shrinkwrap correctly using the correct npm versions

* Remove env handling which wasn't used yet

* Address review comments

* Enforce experiment flag

* Correct failure string

* linter/formatter

* fix tests

* Fix linter warnings

---------

Co-authored-by: Joanna Wang <annajowang@gmail.com>
Co-authored-by: annajowang <31288696+annajowang@users.noreply.github.com>
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