Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Any framework that can generate a build output in accordance with the App Hostin
The output bundle primarily consists of a `bundle.yaml` file that sits inside of the `.apphosting` directory. This bundle.yaml contains all the ways that frameworks can configure App Hosting when users deploy their applications.

> [!NOTE]
> App Hosting technically supports all all node applications, but no custom framework features will be enabled without the output bundle.
> App Hosting technically supports all node applications, but no custom framework features will be enabled without the output bundle.

## Output bundle Schema

Expand All @@ -37,6 +37,7 @@ interface OutputBundle {
version: "v1"
runConfig: RunConfig;
metadata: Metadata;
outputFiles?: OutputFiles;
}
```

Expand Down Expand Up @@ -108,12 +109,44 @@ interface Metadata {
| `framework` | `string` | Name of the framework that is being supported | y |
| `frameworkVersion` | `string` |Version of the framework that is being supported | n |

### OutputFiles

OutputFiles is an optional field to configure outputFiles and optimize server files + static assets.

```typescript
interface OutputFiles {
serverApp: ServerApp
}

```

| Field | Type | Description | Required? |
| ---------- | ------- | - | - |
| `serverApp` | `ServerApp` | ServerApp holds configurations related to the serving files at runtime from Cloud Run | y |

### ServerApp

OutputFiles is an optional field to configure outputFiles and optimize server files + static assets.

```typescript
interface ServerApp {
include: string[]
}

```

| Field | Type | Description | Required? |
| ---------- | ------- | - | - |
| `include` | `string[]` | include holds a list of directories + files relative to the app root dir that frameworks need to deploy to the App Hosting server, generally this will be the output/dist directory (e.g. .output or dist). In the case that the framework wants to include all files they can use [“.”] | y |

## Sample

Here is a sample `.apphosting/bundle.yaml` file putting all this together:

```yaml
version: v1
runConfig:
runCommand: 'node dist/index.js'
runCommand: node dist/index.js
environmentVariables:
- variable: VAR
value: 8080
Expand All @@ -123,6 +156,12 @@ runConfig:
memoryMiB: 512
minInstances: 0
maxInstances: 14

outputFiles:
serverApp:
include:
- dist
- .output

metadata:
adapterPackageName: npm-name
Expand Down
4 changes: 1 addition & 3 deletions packages/@apphosting/adapter-nextjs/src/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ export async function overrideNextConfig(projectRoot: string, nextConfigFileName
* Current overrides include:
* - images.unoptimized = true, unless user explicitly sets images.unoptimized to false or
* is using a custom image loader.
*
* @param importStatement The import statement for the original config.
* @param fileExtension The file extension of the original config. Use ".js", ".mjs", or ".ts"
* @returns The custom Next.js config.
* @return The custom Next.js config.
*/
function getCustomNextConfig(importStatement: string, fileExtension: string) {
return `
Expand Down Expand Up @@ -150,7 +149,6 @@ export async function validateNextConfigOverride(
* This function adds the following headers to all routes:
* - x-fah-adapter: The Firebase App Hosting adapter version used to build the app.
* - x-fah-middleware: When middleware is enabled.
*
* @param appPath The path to the app directory.
* @param distDir The path to the dist directory.
* @param adapterMetadata The adapter metadata.
Expand Down
4 changes: 2 additions & 2 deletions packages/@apphosting/adapter-nextjs/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function loadConfig(root: string, projectRoot: string): Promise<Nex
* Loads the route manifest from the standalone directory.
* @param standalonePath The path to the standalone directory.
* @param distDir The path to the dist directory.
* @returns The route manifest.
* @return The route manifest.
*/
export function loadRouteManifest(standalonePath: string, distDir: string): RoutesManifest {
const manifestPath = join(standalonePath, distDir, ROUTES_MANIFEST);
Expand All @@ -54,7 +54,7 @@ export function loadRouteManifest(standalonePath: string, distDir: string): Rout
* Loads the middleware manifest from the standalone directory.
* @param standalonePath The path to the standalone directory.
* @param distDir The path to the dist directory.
* @returns The middleware manifest.
* @return The middleware manifest.
*/
export function loadMiddlewareManifest(
standalonePath: string,
Expand Down
13 changes: 13 additions & 0 deletions packages/@apphosting/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface OutputBundleConfig {
version: "v1";
runConfig: RunConfig;
metadata: Metadata;
outputFiles?: OutputFiles;
}

// Fields needed to configure the App Hosting server
Expand Down Expand Up @@ -38,6 +39,18 @@ export interface Metadata {
frameworkVersion?: string;
}

// Optional outputFiles to configure outputFiles and optimize server files + static assets.
// If this is not set then all of the source code will be uploaded
interface OutputFiles {
serverApp: ServerApp;
}

// ServerApp holds a list of directories + files relative to the app root dir that frameworks need to deploy to the App Hosting server,
// generally this will be the output/dist directory (e.g. .output or dist). To include all files set this to [“.”]
interface ServerApp {
include: string[];
}

// Represents a single environment variable.
export interface EnvVarConfig {
// Name of the variable
Expand Down