Skip to content

Commit d0e37af

Browse files
HugoGresseclaude
andcommitted
Migrate off functions.config() + bump functions to Node 24
Closes #1669. functions.config() / Cloud Runtime Config is deprecated (shuts down March 2027). The function code already reads everything from process.env via functions/.env* files, so this finishes the migration in the remaining places that still referenced the legacy config: - e2e CI: stop writing the legacy .runtimeconfig.json; convert the nested config secret into functions/.env.local (the dotenv the emulator loads) with jq. - docs/install: replace `firebase functions:config:set` / `functions:config:get > .runtimeconfig.json` with .env instructions. - userInvite trigger: drop the stale functions:config:get comment. Also bump the functions runtime to Node 24 (engines.node + .nvmrc). Note: nodejs24 is GA on Cloud Functions, but firebase-tools <= 15.20.0 (current latest) still caps deploy validation at nodejs22. Until a firebase-tools release adds nodejs24, deploy the functions with `gcloud functions deploy --runtime nodejs24` (or bump firebase-tools once it supports it); plain `firebase deploy` will reject the runtime. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 910416d commit d0e37af

5 files changed

Lines changed: 52 additions & 33 deletions

File tree

.github/workflows/test-e2e.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,25 @@ jobs:
2727
with:
2828
credentials_json: '${{ secrets.E2E_GCLOUD_CREDENTIAL_OPEN_FEEDBACK_CYPRESS }}'
2929

30-
- name: "Create .runtimeconfig.json"
31-
run: 'echo "$RUNTIME_CONFIG_TEST" > functions/.runtimeconfig.json'
30+
# Functions now read config from process.env (functions/.env*), not the
31+
# deprecated functions.config()/.runtimeconfig.json. Convert the legacy
32+
# nested config secret into the dotenv the emulator loads (.env.local).
33+
- name: "Create functions/.env.local"
34+
run: |
35+
echo "$RUNTIME_CONFIG_TEST" | jq -r '
36+
"APP_ENV=\(.app.env // "test")",
37+
"APP_URL=\(.app.url // "")",
38+
"APP_CONTACTEMAIL=\(.app.contactemail // "")",
39+
"APP_RECAPTCHAV3SECRET=\(.app.recaptchav3secret // "")",
40+
"MAILGUN_DOMAIN=\(.mailgun.domain // "")",
41+
"MAILGUN_KEY=\(.mailgun.key // "")",
42+
"MAILGUN_API=\(.mailgun.api // "")",
43+
"OPSGENIE_KEY=\(.opsgenie.key // "")",
44+
"OPSGENIE_API=\(.opsgenie.api // "")"
45+
' > functions/.env.local
3246
shell: bash
3347
env:
3448
RUNTIME_CONFIG_TEST: ${{secrets.RUNTIME_CONFIG_TEST}}
35-
- name: "test"
36-
run: 'cat functions/.runtimeconfig.json'
37-
shell: bash
3849

3950
- name: Install functions dependencies
4051
run: |

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20
1+
24

docs/app/1-install.mdx

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,48 @@ The application sends emails through the Mailgun API
3535

3636
You have to create a Mailgun account if you want to send those emails, if not the app will still works perfectly but without sending any email.
3737

38-
Mailgun API is used to send email through Cloud Functions, so you will have to add environment variables with Firebase CLI:
38+
Mailgun API is used to send email through Cloud Functions. Configuration uses
39+
environment variables (the [Firebase params/env approach](https://firebase.google.com/docs/functions/config-env);
40+
the legacy `functions.config()` / Runtime Config is deprecated). Add the
41+
variables to a dotenv file under `functions/`:
3942

40-
- The application URL: app.url (ex: `http://localhost:3000`)
41-
- The API key: mailgun.key
42-
- The domain name: mailgun.domain
43-
- The Mailgun API url: mailgun.api (ex https://api.eu.mailgun.net/v3/SOMETHINGLIKE_THIS/messages)
43+
- The application URL: `APP_URL` (ex: `http://localhost:3000`)
44+
- The API key: `MAILGUN_KEY`
45+
- The domain name: `MAILGUN_DOMAIN`
46+
- The Mailgun API url: `MAILGUN_API` (ex https://api.eu.mailgun.net/v3/SOMETHINGLIKE_THIS/messages)
4447

45-
Here the command to register those variables:
48+
Firebase loads `functions/.env` (all projects), `functions/.env.<project-id>`
49+
(per project, used on deploy), and `functions/.env.local` (used by the
50+
emulator only). Example `functions/.env.local`:
4651

47-
firebase functions:config:set app.url="https://myserver.com" mailgun.key="MAILGUN API KEY" mailgun.domain="MAILGUN DOMAIN" mailgun.api="https://api.eu.mailgun.net/v3/SOMETHINGLIKE_THIS/messages"
52+
APP_ENV=development
53+
APP_URL=https://myserver.com
54+
MAILGUN_KEY=MAILGUN_API_KEY
55+
MAILGUN_DOMAIN=MAILGUN_DOMAIN
56+
MAILGUN_API=https://api.eu.mailgun.net/v3/SOMETHINGLIKE_THIS/messages
4857

49-
To test cloud functions with Mailgun on your local machine (with cloud function shell), you will need to generate ``.runtimeconfig.json` file with environment variables :
50-
51-
firebase functions:config:get > .runtimeconfig.json
58+
> Keep secrets out of version control: store them in a gitignored `.env*.local`
59+
> (or use [Cloud Secret Manager](https://firebase.google.com/docs/functions/config-env#secret-manager)).
5260
5361
> Important Note: Mailgun is an external service from Firebase and Google, so to be able use it with you will need to activate Firebase pricing.
5462
5563
### Configure OpsGenie (optional)
5664
The application report alerting using OpsGenie, it is optional and the app will still works perfectly but without any alerting.
5765

58-
You will have to add environment variables with Firebase CLI:
59-
60-
- The application URL: app.url (ex: `http://localhost:3000`)
61-
- The OpsGenie API key: opsgenie.key
62-
- The OpsGenie api domain: opsgenie.api
63-
- For contact email (optional): app.contactemail
64-
- For contact email captcha, the recaptcha V3 Secret: app. recaptchav3secret
65-
66-
Here the command to register those variables:
66+
Add the following environment variables to a `functions/` dotenv file (see the
67+
Mailgun section above for how Firebase loads them):
6768

68-
firebase functions:config:set app.url="https://myserver.com" opsgenie.api="https://api.eu.opsgenie.com" opsgenie.key="xxxxx-xxxxxx-xxxxxx-xxxxx"
69+
- The application URL: `APP_URL` (ex: `http://localhost:3000`)
70+
- The OpsGenie API key: `OPSGENIE_KEY`
71+
- The OpsGenie api domain: `OPSGENIE_API`
72+
- For contact email (optional): `APP_CONTACTEMAIL`
73+
- For contact email captcha, the recaptcha V3 Secret: `APP_RECAPTCHAV3SECRET`
6974

70-
To test alerting on your local machine (with cloud function shell), you will need to generate ``.runtimeconfig.json` file with environment variables :
75+
Example additions to `functions/.env.local`:
7176

72-
firebase functions:config:get > .runtimeconfig.json
77+
APP_URL=https://myserver.com
78+
OPSGENIE_API=https://api.eu.opsgenie.com
79+
OPSGENIE_KEY=xxxxx-xxxxxx-xxxxxx-xxxxx
7380

7481
> Important Note: OpsGenie is an external service from Firebase and Google, so to be able use it with you will need to activate Firebase pricing.
7582
@@ -98,10 +105,11 @@ Cloud functions uses its own `package.json`, first install dependencies. From th
98105
npm i
99106
```
100107

101-
And then from the root of the project:
108+
And then add the admin contact email to `functions/.env.<your-project-id>`
109+
(created automatically on first deploy if missing):
102110

103111
```
104-
firebase functions:config:set 'app.contactemail=<ADMIN_EMAIL>'
112+
APP_CONTACTEMAIL=<ADMIN_EMAIL>
105113
```
106114

107115
The next deploy will also deploy Firebase Cloud Functions

functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"test": "vitest"
1414
},
1515
"engines": {
16-
"node": "20"
16+
"node": "24"
1717
},
1818
"main": "lib/index.js",
1919
"dependencies": {

functions/src/triggers/invites/userInvite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { onDocumentCreated } from 'firebase-functions/v2/firestore'
1010

1111
// userInviteCreated is called when an user as been invited to a project or an organization.
1212
// An email is sent to him with the invitation link.
13-
// To test
14-
// > firebase functions:config:get > .runtimeconfig.json
13+
// To test (config comes from functions/.env* via process.env, not the
14+
// deprecated functions.config()):
1515
// > firebase functions:shell
1616
// - for event/project
1717
// > userInviteCreated({projectId: "", projectName: "", originUserName: "", destinationUserInfo: ""})

0 commit comments

Comments
 (0)