Skip to content

Commit c3de090

Browse files
authored
Add App Hosting as an option for firebase init (#7803)
* init apphosting.yaml
1 parent b776cc1 commit c3de090

6 files changed

Lines changed: 46 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Added App Hosting as an option for firebase init. (#7803)

src/commands/init.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ let choices: {
8787
checked: false,
8888
hidden: true,
8989
},
90+
{
91+
value: "apphosting",
92+
name: "App Hosting: Configure an apphosting.yaml file for App Hosting",
93+
checked: false,
94+
hidden: false,
95+
},
9096
];
9197

9298
if (isEnabled("genkit")) {

src/init/features/apphosting.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as clc from "colorette";
2+
import * as utils from "../../utils";
3+
import { Config } from "../../config";
4+
import { readTemplateSync } from "../../templates";
5+
6+
const APPHOSTING_YAML_TEMPLATE = readTemplateSync("init/apphosting/apphosting.yaml");
7+
8+
/**
9+
* Set up an apphosting.yaml file for a new App Hosting project.
10+
*/
11+
export async function doSetup(setup: any, config: Config): Promise<void> {
12+
utils.logBullet("Writing default settings to " + clc.bold("apphosting.yaml") + "...");
13+
await config.askWriteProjectFile("apphosting.yaml", APPHOSTING_YAML_TEMPLATE);
14+
}

src/init/features/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export { doSetup as remoteconfig } from "./remoteconfig";
1212
export { initGitHub as hostingGithub } from "./hosting/github";
1313
export { doSetup as dataconnect } from "./dataconnect";
1414
export { doSetup as dataconnectSdk } from "./dataconnect/sdk";
15-
export { doSetup as apphosting } from "../../apphosting";
15+
export { doSetup as apphosting } from "./apphosting";
1616
export { doSetup as genkit } from "./genkit";

src/init/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const featureFns = new Map<string, (setup: any, config: any, options?: any) => P
3232
["remoteconfig", features.remoteconfig],
3333
["hosting:github", features.hostingGithub],
3434
["genkit", features.genkit],
35+
["apphosting", features.apphosting],
3536
]);
3637

3738
export async function init(setup: Setup, config: any, options: any): Promise<any> {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Settings for Backend (on Cloud Run).
2+
# See https://firebase.google.com/docs/app-hosting/configure#cloud-run
3+
runConfig:
4+
minInstances: 0
5+
# maxInstances: 100
6+
# concurrency: 80
7+
# cpu: 1
8+
# memoryMiB: 512
9+
10+
# Environment variables and secrets.
11+
# env:
12+
# Configure environment variables.
13+
# See https://firebase.google.com/docs/app-hosting/configure#user-defined-environment
14+
# - variable: MESSAGE
15+
# value: Hello world!
16+
# availability:
17+
# - BUILD
18+
# - RUNTIME
19+
20+
# Grant access to secrets in Cloud Secret Manager.
21+
# See https://firebase.google.com/docs/app-hosting/configure#secret-parameters
22+
# - variable: MY_SECRET
23+
# secret: mySecretRef

0 commit comments

Comments
 (0)