Skip to content

Commit 88d5ef2

Browse files
falahatannajowang
authored andcommitted
Barebones implementation of local builds (#10101)
* 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>
1 parent e44d873 commit 88d5ef2

12 files changed

Lines changed: 522 additions & 44 deletions

File tree

npm-shrinkwrap.json

Lines changed: 155 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
]
105105
},
106106
"dependencies": {
107-
"@apphosting/build": "^0.1.6",
107+
"@apphosting/build": "^0.1.7",
108108
"@apphosting/common": "^0.0.8",
109109
"@electric-sql/pglite": "^0.3.3",
110110
"@electric-sql/pglite-tools": "^0.2.8",
@@ -168,6 +168,7 @@
168168
"stream-chain": "^2.2.4",
169169
"stream-json": "^1.7.3",
170170
"superstatic": "^10.0.0",
171+
"tar": "^7.5.11",
171172
"tcp-port-used": "^1.0.2",
172173
"tmp": "^0.2.3",
173174
"triple-beam": "^1.3.0",

src/apphosting/localbuilds.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ import { BuildConfig, Env } from "../gcp/apphosting";
22
import { localBuild as localAppHostingBuild } from "@apphosting/build";
33

44
/**
5-
* Triggers a local apphosting build.
5+
* Triggers a local build of your App Hosting codebase.
6+
*
7+
* This function orchestrates the build process using the App Hosting build adapter.
8+
* It detects the framework (though currently defaults/assumes 'nextjs' in some contexts),
9+
* generates the necessary build artifacts, and returns metadata about the build.
10+
* @param projectRoot - The root directory of the project to build.
11+
* @param framework - The framework to use for the build (e.g., 'nextjs').
12+
* @return A promise that resolves to the build output, including:
13+
* - `outputFiles`: Paths to the generated build artifacts.
14+
* - `annotations`: Metadata annotations relating to the build.
15+
* - `buildConfig`: Configuration derived from the build process (e.g. run commands, environment variables).
616
*/
717
export async function localBuild(
818
projectRoot: string,

0 commit comments

Comments
 (0)