Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue #364 #814

Merged
merged 2 commits into from
Jun 29, 2018
Merged

Fixes issue #364 #814

merged 2 commits into from
Jun 29, 2018

Conversation

remie
Copy link
Contributor

@remie remie commented Jun 29, 2018

Description

As described in #364, it is not possible to run firebase serve --only functions in a dockerized environment because for some reason configstore.get('tokens') does not contain any values, regardless of whether you pass --token or set the FIREBASE_TOKEN environment variable.

What does work, is to actually switch to process.env.FIREBASE_TOKEN if there isn't a set of tokens available in the config store. This will also work with --token.

Scenarios Tested

Create a new Firebase Functions project with firebase-tools, Dockerize the application with firebase serve --only functions --token $FIREBASE_TOKEN as the command, or with FIREBASE_TOKEN=<TOKEN> firebase serve --only functions and watch it run smoothly.

Sample Dockerfile

FROM node:8

ARG FIREBASE_TOKEN
ARG FB_PROJECTID
ENV FIREBASE_TOKEN ${FIREBASE_TOKEN}
ENV FB_PROJECTID ${FB_PROJECTID}

WORKDIR /opt/sample
COPY ./firebase.json firebase.json

WORKDIR /opt/sample/functions
COPY ./functions/package.json package.json
COPY ./functions/package-lock.json package-lock.json
RUN npm install; \
        npm install -g firebase-tools; \
	firebase use $FB_PROJECTID;

COPY ./functions/src src
COPY ./functions/tsconfig.json tsconfig.json
COPY ./functions/tslint.json tslint.json

CMD ["npm", "run", "serve"]

@mbleigh mbleigh merged commit b342ba7 into firebase:master Jun 29, 2018
joehan added a commit that referenced this pull request Apr 26, 2024
* Added description for experiments:list command (#6363)

* fix `npm root` issues on Next.js deploy (#6372)

* increase npm root timeout to 5s

* memoize npm root

* changelog

* Fix npm packaging so that npm commands work (#6367)

Co-authored-by: joehan <[email protected]>

* Added a check to see if export target folder is empty (#6357)

* check if export target folder is empty

* Updated CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: joehan <[email protected]>

* Changed promptOnce to confirm

---------

Co-authored-by: joehan <[email protected]>

* Improve performance and reliability when deploying multiple 2nd gen functions using single builds (#6376)

* enable single builds v2

* Fix Issue #6382 Firebase not working for NextJs >=v13.5.0 (#6404)

* Fix Issue #6382 Firebase not working for NextJs >=v13.5.0

Fixes #6382

Due to braking changes on the signature of loadConfig (https://github.com/vercel/next.js/blob/d96e0258de2caf34e9322d0d32ab5748533c4465/packages/next/src/server/config.ts#L784) Firebase does not deploy correctly.

* Changelog

---------

Co-authored-by: Ferid Zuber <[email protected]>

* Fix retry for event triggered functions (#6391)

* linking up retry to the api call

* add changelog entry

---------

Co-authored-by: joehan <[email protected]>

* 12.6.0

* [firebase-release] Removed change log and reset repo after 12.6.0 release

* Support non-ASCII file names in `appdistribution:distribute` (#6409)

* Use default bucket api (#6406)

* Call GetDefaultBucket in FirebaseStorage

* Correctly set FUNCTION_TARGET for grouped functions (#6410)

* Fix service account option to be a param (#6389)

* treat the service account option as a param

* add changelog entry

---------

Co-authored-by: joehan <[email protected]>

* 12.6.1

* [firebase-release] Removed change log and reset repo after 12.6.1 release

* Use correct bucket name field when reading DefaultBucket for storage (#6420)

* Correctly set FUNCTION_TARGET for multilevel grouped functions (#6423)

Co-authored-by: joehan <[email protected]>

* Fixed an issue where functions deployment required a new permission. (#6425)

* - Fixed an issue where functions deployment required a new permission.

* pretty

---------

Co-authored-by: joehan <[email protected]>

* 12.6.2

* [firebase-release] Removed change log and reset repo after 12.6.2 release

* Allow enabling and disabling PITR on Firestore databases (#6427)

Also show Point In Time Recovery setting, earliest version time, and version retention period on get

* Rename frameworks experiment to internalframeworks to avoid confusion. (#6439)

* Rename frameworks experiment to internalframeworks to avoid confusion.

* Missed a spot.

* Resolve vpc value prior to checking it's value (#6332)

* fix: resolve vpc value prior to checking it's value

closes #6327

* chore: correct endpoint resolution

* style: correct linting

* fix: do not overwrite entire object

---------

Co-authored-by: joehan <[email protected]>

* Add verbosity flag (#6429)

* Add verbosity flag

* Fixme fix

* Changed name, added SILENT

---------

Co-authored-by: joehan <[email protected]>

* Ignore Firestore emulator host on functions deploy (#6442)

* do not read firestore emulator env var on deploy

Co-authored-by: joehan <[email protected]>

* Adding changelog for #2859 and #6327 (#6440)

* Fix type mismatch for parametrized function region (#6205)

* fix type mismatch for region param

* 12.7.0

* [firebase-release] Removed change log and reset repo after 12.7.0 release

* Enable preferRest option by default for Firestore functions (#6147)

* enable preferRest option by default

* update changelog

* Update CHANGELOG.md

Co-authored-by: Jeff <[email protected]>

* Fix bug where 2nd Gen firestore functions were mistakenly parsed as pubsub function (#6456)

Firestore trigger also includes pubsubTopic since they use pubsub as transport. This triggered a bug where 2nd Gen Firestore bugs were being parsed as pubsub function which manifests in bugs like #6453.

* Update CHANGELOG.md to include #6453 (#6464)

* Update CHANGELOG.md to include #6453

* Update CHANGELOG.md

---------

Co-authored-by: joehan <[email protected]>

* corrects regex for domain matching authorized domains (#6479)

* corrects regex for domain matching authorized domains

* add changelog

* Init flow demo (#6218)

* testing

* testing

* Init demo flow

* Create Stack request body changed

* Updated CRUD API's for stacks

* Updated changes

* updated comments

* Update CRUD options

* resolved comments

* resolved comments

* resolved comments

* Changing stack to backend in APIs

* Added changes to modify api

* minor change to region

* Added error messages

* catch block added

* Added few changes

* Returned stack

* Return stack

* Added return statements

* Removed comments

* changed comments

* Added minor change

* Format code

* Format code

* 12.8.0

* [firebase-release] Removed change log and reset repo after 12.8.0 release

* Svn main 001 rem (#6486)

* Change name from stack to backend

* Change name from stack to backend

* changed file names

* changed file names in experiments

* changed name

* lower case backend

* Fix two issues with Firestore database updating: (#6478)

* Performing an update on a Datastore mode database could silently change it to Firestore Native
* Enabling PITR (--point-in-time-recovery=ENABLED) while not specifying --disaster-recovery=ENABLED
  would silently disable disaster recovery, and vice-versa

 The former issue was due to always sending FIRESTORE_NATIVE as the database type, when we
 actually didn't need to send it at all. The latter issue was due to command-line option
 parsing that assumed not specifying an option was equivalent to sending an explicit DISABLE.

* Svn main 001 rem (#6489)

* Change name from stack to backend

* Change name from stack to backend

* changed file names

* changed file names in experiments

* changed name

* lower case backend

* Changed stack to backend

* change stack to backend in index file

* List stacks in table

* Backends for project message

* resolve merge conflicts

* removed linter errors

* changed table head color to green

* test method stack to backend

* Changed stack to backend (#6488)

* Changed stack to backend

* change stack to backend in index file

* List stacks in table

* Backends for project message

* Changed file names

* removed linter errors

* change file names from stack to backend

* changed table head color to green

* test method stack to backend

* changed file name

* 12.8.1

* [firebase-release] Removed change log and reset repo after 12.8.1 release

* Svn main 001 rem (#6492)

* Change name from stack to backend

* Change name from stack to backend

* changed file names

* changed file names in experiments

* changed name

* lower case backend

* Changed stack to backend

* change stack to backend in index file

* List stacks in table

* Backends for project message

* resolve merge conflicts

* removed linter errors

* changed table head color to green

* test method stack to backend

* Changed stack to backend (#6488)

* Changed stack to backend

* change stack to backend in index file

* List stacks in table

* Backends for project message

* Changed file names

* removed linter errors

* change file names from stack to backend

* changed table head color to green

* test method stack to backend

* changed file name

* Change Stack objects to Backend (#6490)

* Change Stack objects to Backend

* formatted files

* Fix blocking functions in the emulator when using multiple codebases (#6504)

* fix emulator bug

* Add changelog entry

* Add force flag call-out for bypassing prompts (#6506)

* add min instances callout

* add changelog entry

* update to skip all prompts

* Ensure functionsEmulator respects logVerbosity (#6521)

* adds a check for a hosting site to exist in hosting init (#6493)

* adds a check for a hosting site to exist in hosting init

* formatting is hard

* sites:create now will better prompt for a site name if one isn't provided

* fix non-interactive flow

* better organize catch block

* protect deploy and channel:deploy with errors

* linting is hard

* always make good and valid suggestions for site creation

* formatting is hard

* rm experiment

* add changelog

* Revert "Enable preferRest option by default for Firestore functions" (#6520)

* revert enabling preferrest by default

* 12.9.0

* [firebase-release] Removed change log and reset repo after 12.9.0 release

* fix issues where project ID was missing in Hosting setup (#6528)

* fix issues where project ID was missing in Hosting setup

fixes #6527

* formatting is SO HARD

* 12.9.1

* [firebase-release] Removed change log and reset repo after 12.9.1 release

* Updated backends:list command. (#6519)

* Updated backends:list command w.r.t M2

* formatting file

* Added changes to backends:list

* resolved linter errors

* Updated delete command for M2 (#6525)

* Updated delete command for M2

* removed unused variable

* Added changes to backends:get operation for M2 (#6524)

* Added changes to backends:get operation for M2

* Modified backends:get command

* Modified backends:get command swapped position of location and uri in output

* updated error message

* updated location in all rows

* resolved unsupported argument errors

* change error to info meassage

* Updated the backends:create flow for M2. (#6518)

* Updated the backends:create flow for M2.

* added branch as main to send

* changes to output

* Angular v17 support  (#6480)

* Updated the documentation to reflect Angular v17
* Added support for the application builder
* Renamed the existing builders to LEGACY_* so it's clearer the code we can deprecate later
* Cleaned up some of the mess in getContext & adding more guardrails

---------

Co-authored-by: Paweł Kubiak <[email protected]>

* Feature: login:use can be used outside of Firebase project to change the global default account. (#6533)

* logic: set user outside proj

* remove: comment out

* remove: log, lint

* add: change log

* Don't prompt on non-interactive mode (#6541)

* Don't prompt on non-interactive mode

* Updated changelog

* Updated changelog

---------

Co-authored-by: joehan <[email protected]>

* fix: properly warn users not to use "=" character in pre or post deploy commands (#6503)

Co-authored-by: joehan <[email protected]>

* Better error message when failing to fetch MOTD (#6556)

* Better error message when failing to fetch MOTD

* Update src/fetchMOTD.ts

Co-authored-by: Bryan Kendall <[email protected]>

* format

---------

Co-authored-by: Bryan Kendall <[email protected]>

* BREAKING: Ignore 'functions' directory in a Firebase project without a functions config in firebase.json (#6555)

Historically, Firebase CLI reserved directory named `functions` inside a Firebase project directory for use by Cloud Functions for Firebase. This meant that if `functions` directory exists, it was assumed to hold CF3 source code.

However, we recognize that there are valid use case for using `functions` directory name, especially in monorepo-like setups.

With this change, Firebase CLI will only reserve `functions` directory when there is a `functions` configuration entry in firebase.json that does not specify the `source` directory.

This change will be released in the next breaking change of the Firebase CLI (v13).

Fixes #6450

* Fix Angular SSR deployment on Windows (#6544)

fixes #6543

* On NextJS deploy check if `not-found` is static (#6558)

* use only site id in list versions API (#6565)

* Install missing dependencies during clean install by default (#6572)

Currently npx prompts for confirmation from user to install missing dependencies
when running the script. However, there is now a use case (b/299490916) that
requires the script to be run unattendedly. `--yes` suppresses the prompt
(https://docs.npmjs.com/cli/v10/commands/npx).

See b/299490916 and go/firebase-3p-frameworks-compatibility-testing for more details.

* Add utility function to list GCB connections w/ well-known names. (#6535)

Update naming convention for GCB connection maintained by the frameworks service. In the meantime, add a small utility feature that can filters all GCB connections for frameworks-maintained ones.

* Make FIREBASE_FRAMEWORKS_VERSION injectable for testing (#6571)

* Make FIREBASE_FRAMEWORKS_VERSION injectable for testing

When `internaltesting` experiment is enabled, the value for
`FIREBASE_FRAMEWORKS_VERSION` shall be derived from the environment
variable with the same name.

This is only intended for testing purposes. Code behavior for
production does not change.

---------

Co-authored-by: James Daniels <[email protected]>

* Manage GCB connection resources more efficiently (#6536)

During onboarding, the CLI will create only the necessary GCB connection and repositories.

Unlike previous implemention where a connection was created per project/region, the new algorithm manages a single "oauth" connection resource and the same project/region connection. The new implementation also biases heavily towards reusing the GCB connection when any valid connection already exists in the project.

See internal doc for more detail.

The specific format for naming the GCB connection resource is one shared with the Firebase console so that all Firebase client manages the GCB resource in the same way.

* Launch/v13.0.0 (#6559)

* Update min node version to 18, add 20 to supported versions & CI

* Update min node version to 18, add 20 to supported versions & CI (#6447)

* Update min node version to 18, add 20 to supported versions & CI

* Fix broken unit test

* Bump dockefiles to Node 20 as well

* Skip frameworks test for now so that it doesn't run indefinitely

* GetStorageDefaultBucket through Storage API (#6471)

* GetStorageDefaultBucket through Storage API

* pretty it up

* Update CHANGELOG.md

---------

Co-authored-by: joehan <[email protected]>

* Remove 'request' from 'functions:shell' (#5808)

* removing request and api from functions shell

* typing is powerful

* return sentinal value on http function to avoid weird output

* fix get/post functions to accept data

* spelling is hard

* Cleaning up old code

* Replace request with a shim

* refactoring to pipe through body correctly

* Use correct function signature

* format

* format

* remove overly specific error message

* remove request from storage-integration-test

* formats

---------

Co-authored-by: Bryan Kendall <[email protected]>

* Removing deprecated ext:dev:publish, as promised (#6522)

* Added CHANGELOG entries

* Updating various test dependencies

* Update functions node version error message

* First crack at getting webframeworks tests back up and running (#6573)

* First crack at getting webframeworks tests back up and running

* More dep upates, specify type:modules for functions

* Update Angular

* --exit on mocha, fixes for Angular

* Lint

* Next14

* Couple nextjs tests

* More stuffs

---------

Co-authored-by: James Daniels <[email protected]>

* Better error message for missing storage default bucket (#6575)

* Better error message for missing storage default bucket

* ===

* ===

* format

---------

Co-authored-by: abhis3 <[email protected]>
Co-authored-by: Bryan Kendall <[email protected]>
Co-authored-by: James Daniels <[email protected]>

* 13.0.0

* [firebase-release] Removed change log and reset repo after 13.0.0 release

* Fix tiny bug where backends:list command fails when API responds without any backend resources. (#6547)

Previously, the command threw an error given a project with no backends.

* Ensure API is enabled for frameworks commands. (#6548)

Before running any frameworks command, we ensure that the API is enabled.

* Allow GCB repos to be reused in backend. (#6579)

Previously, we assumed that each new GCB Repository resource would be associated with at most 1 backends. Our new data model now allows GCB Repository to be reused across different backends. Updating code to reflect the change.

* Include serving locality in create backend requests. (#6577)

Backends resource now require setting up servingLocality when creating a new backend.

* Prompt required IAM permission during frameworks onboarding. (#6576)

Before the CLI attempts to create a connection to GitHub using the Cloud Build API, the CLI now prompts the user if they want the CLI to grant the necessary IAM permissions on the Cloud Build Service Agent (as documented in the [Cloud Build public doc](https://cloud.google.com/build/docs/automating-builds/github/connect-repo-github?generation=2nd-gen#iam_perms)):

```
i To create a new GitHub connection, Secret Manager Admin role (roles/secretmanager.admin) is required on the Cloud Build Service Agent.
? Grant the required role to the Cloud Build Service Agent? Yes
✅ Successfully granted the required role!
```

* Make consistent use of logger during backends onboarding (#6578)

Use utility log functions, like logBullet, instead of raw logger for consistent log style during backends onboarding.

e.g.

**Before**
```
i  First we need a few details to create your backend.
? Create a name for your backend [1-30 characters] adsad
? Please select a region (info: Your region determines where your backend is located):
 us-central1 (Iowa)
✔  Region set to us-central1.

=== Connect a GitHub repository
To create a new GitHub connection, Secret Manager Admin role (roles/secretmanager.admin) is required on the Cloud Build Service Agent.
...
```

**After**
```
...
i === Connect a GitHub repository
i To create a new GitHub connection, Secret Manager Admin role (roles/secretmanager.admin) is required on the Cloud Build Service Agent.

...
...

* Refactor createBackend and other utility functions. (#6580)

As written, various utility command used for onboarding uses untyped `setup` object. Making a small refactoring here to explicitly pull out `backenId`, `locations`, and other variables that's used throughout the module.

* Update backends:get command to match approved API design. (#6581)

As written, `backend:get` accepts a `--backend` flag:

```
firebase backends:get --backend foo
```

However, the approved API design accepts backend as an argument instead:

```
firebase backends:get foo
```

* ng-deploy may not have configurations configured... (#6584)

* Grab the raw options, if a configuration isn't present
* Accept serveTarget from ng-deploy, setting this by default in angularfire@17

* Add well known version ranges to Web Frameworks (#6562)

* Limit web frameworks generated functionId to 20 chars max (#6260)

* [Fix] Astro relatives dirs (#5709)

Use fileURLToPath to address astro relative directories

---------

Co-authored-by: James Daniels <[email protected]>

* Strip special characters from vite output (#6588)

Fix issue #5561 emulators not starting with vite

---------

Co-authored-by: Viktor Sotov <[email protected]>
Co-authored-by: sotovviktor <[email protected]>

* Add `nuxt.md` to docs (#6303)

Co-authored-by: Leonardo Ortiz <[email protected]>

* Update ALLOWED_SSR_REGIONS constant for web frameworks (#6591)

Update list of `ALLOWED_SSR_REGIONS` in web frameworks config to include the current list of regions that support gen 2 Cloud Functions.

---------

Co-authored-by: James Xabregas <[email protected]>
Co-authored-by: Alex Astrum <[email protected]>

* add nuxt init method for firebase hosting (#6309)

* add nuxt init method for firebase init hosting
* Changelog, supportedRange, and address feedback

---------

Co-authored-by: Leonardo Ortiz <[email protected]>
Co-authored-by: James Daniels <[email protected]>

* Rolling firepit back to node 18 (#6589)

* Memoize firestore.getDatabase API calls when deploying Firestore functions (#6583)

During deployment of a 2nd Gen Firestore functions, the CLI retrieves metadata associated with the Firestore database in order to ensure that the region of the Firestore database matches the region of the deployed function:

https://github.com/firebase/firebase-tools/blob/1f4f6f494fd7a8a29887a8306930cda56aa7e13b/src/deploy/functions/services/firestore.ts#L9-L15

Unfortunately, when a large number of functions are deployed that each target a different Firestore instance (you are allowed to have multiple instances of Firestore on a single GCP project), developer will likely see a quota exceeds error:

```
Quota exceeded for quota metric 'Database operation requests' and limit 'Database Operations Per Minute' of service 'firestore.googleapis.com' for consumer ...
```

We mitigate the issue by memoizing the API calls. This should help with cases where multiple firestore functions are associated with a database, but wouldn't help if developer is setting up and deploying 60+ unique functions.

Mitigates #6574

* Ensure that depedent APIs are enabled during Backend creation flow. (#6595)

* Clearing out some scanner vulns (#6590)

Co-authored-by: joehan <[email protected]>

* Fix bug where connection single repository properly prompted. (#6596)

* 13.0.1

* [firebase-release] Removed change log and reset repo after 13.0.1 release

* fix Next.js dynamic and static OG images  (#6592)

Fixed by adding the VERCEL_URL env var

---------

Co-authored-by: James Daniels <[email protected]>

* Fix for the default import of strip-ansi (#6599)

* Fix bug where backends:list and backends:get command fails when no backends exists. (#6600)

---------

Co-authored-by: aalej <[email protected]>
Co-authored-by: Leonardo Ortiz <[email protected]>
Co-authored-by: Hugo Visser <[email protected]>
Co-authored-by: blidd-google <[email protected]>
Co-authored-by: Ferid Zuber <[email protected]>
Co-authored-by: Cole Rogers <[email protected]>
Co-authored-by: Google Open Source Bot <[email protected]>
Co-authored-by: Anthony Barone <[email protected]>
Co-authored-by: abhis3 <[email protected]>
Co-authored-by: Bob "Wombat" Hogg <[email protected]>
Co-authored-by: Daniel Lee <[email protected]>
Co-authored-by: steveoh <[email protected]>
Co-authored-by: christhompsongoogle <[email protected]>
Co-authored-by: Jeff <[email protected]>
Co-authored-by: Bryan Kendall <[email protected]>
Co-authored-by: Sairam Sakhamuri <[email protected]>
Co-authored-by: James Daniels <[email protected]>
Co-authored-by: Paweł Kubiak <[email protected]>
Co-authored-by: Yuki Takada (Yukinosuke Takada) <[email protected]>
Co-authored-by: Russell Wheatley <[email protected]>
Co-authored-by: Jonas <[email protected]>
Co-authored-by: Yifan Yang <[email protected]>
Co-authored-by: Alex Astrum <[email protected]>
Co-authored-by: Geoffrey-Pliez <[email protected]>
Co-authored-by: Viktor Sotov <[email protected]>
Co-authored-by: sotovviktor <[email protected]>
Co-authored-by: ju <[email protected]>
Co-authored-by: James Xabregas <[email protected]>
yuchenshi pushed a commit that referenced this pull request Sep 18, 2024
add: dataconnect quickstart
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.

2 participants