Mupx fail deployment with settings.json - meteor

For those who use Digital Ocean for hosting and mupx for deployment:
I can not successfully implement usage of settings.json file to run on deployment. Previously it caused failure of deployment, and now, for instance, when I tried to add the package okgrow:analytics, it doesn't work and this appear on browser console:
Missing analyticsSettings in Meteor.settings.public
although it is there.
{
"public": {
"analyticsSettings": {
"Google Analytics" : {
"trackingId": "xxxxxxx"
}
}
}
}
When running locally, one has to type meteor --settings settings.json to start the app. Is there something equivalent for the mupx? How can I configure accordingly?
Needless to say, I need settings.json for sensitive data which shall be ignored for git as well. Perhaps just meteor command should first check if settings.json exists, and accordingly run with the settings inside (if any). Then one doesn't need to type meteor --settings settings.json...

I realised my problem was due to having the settings.json file in the root of the project rather than within the mupx deploy folder.
It was sufficient, then, to just run mupx deploy

Related

GCP: how to make sure that gcp project is set in Cloud Shell Editor

I am toying around a bit with GCP cloud shell editor which I start by visiting https://shell.cloud.google.com/?show=ide (which I installed as an PWA) and would like to debug a simple Flask AppEngine app. The app is using Cloud Logging. It runs fine in the terminal window when I first do:
gcloud config set project myproject
However if I want to use the builtin debugging I get errors because gcloud config set project myproject has not been set in that new window. So my question is how do I make sure that gcloud config set project myproject is run at startup of each console? I already tried running a preLaunchTask but since that is run in a separate console it does not help
Update (26 Jan 2021)
Also toyed around with trying to change the .bashrc automatically when opening a project by using a task that is triggered by folderOpen and then writes the relevant gcloud command to a script which is called by .bashrcas shown below
{
"version": "2.0.0",
"tasks": [
{
"label": "Set GCP Project",
"type": "shell",
"command": "echo \"set -x; gcloud config set project [MYPROJECT]\" > $HOME/set_gcp_project",
"runOptions": {
"runOn": "folderOpen"
},
"presentation": {
"reveal": "never",
"panel": "shared"
},
"problemMatcher": []
}
]
}
However Cloud Shell does not support these automated tasks. It works fine in VSCode. However it is still a nuisance because if in the GCP console I open a terminal or it opens it when you click on a run in cloud shell it sets the project to whatever project I had last opened in the Cloud Shell Editor
If you are interested in customizing your Cloud Shell experience you can always refer to the following section of the documentation.
I guess the must straightforward to always guarantee that the gcloud config set project myproject is always run when a new window is opened will be to append that gcloud command at the end of the .bashrc file located at your $HOME directory.
Just open the Cloud Shell (make sure you are located at the $HOME directory, which is the default directory that opens up when you open your Cloud Shell) and append the gcloud command by running the following command:
[YOUR-USERNAME]#cloudshell:~ (myproject)$ echo "gcloud config set project myproject" >> .bashrc

How do I read a file from the local file system from inside a meteor app?

I have a meteor app that needs to periodically read a file located on the host's file system, outside of the app package. I am using node's fs to accomplish this, and it works fine on my (macOS) development machine.
However, when I run mup deploy to deploy it to my (Ubuntu 14) server, mup returns the following error after starting meteor:
Error: ENOENT: no such file or directory, open '/home/sam/data/all_data.json'
at Object.fs.openSync (fs.js:652:18)
at Object.fs.readFileSync (fs.js:553:33)
Does anyone know why this might be happening?
you should follow mup documentation closely. Have you seen volumes setup in mup config? Try this to solve your issue.
Reason: mup runs app in docker without any access to host file system unless specified. Volumes setup does this for you with mup deployment.
Below is the part of mup config from http://meteor-up.com/docs.html, Everything Configured, read more to get a better idea.
name: 'app',
path: '../app',
// lets you add docker volumes (optional). Can be used to
// store files between app deploys and restarts.
volumes: {
// passed as '-v /host/path:/container/path' to the docker run command
'/host/path': '/container/path',
'/second/host/path': '/second/container/path'
},
The user you have that is running your meteor build on the server needs to have access to that folder - read access. I would store the file in a different directory than the home one, because you don't want to mess it up. Either way doing something like chmod -R 444 /home/sam/data should give read access to any user for all files in that directory. You are probably running meteor as your local user(sam?) in development mode on your macOS, but the built up gets run as meteor or some other user on ubuntu, because of mup and forever.

Error: Functions did not deploy properly

Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error:
Functions did not deploy properly.
Try running deploy with --debug. For example: firebase --debug deploy.
In my case the function looked like this:
exports.test = functions.firestore.document('chats').onCreate((snap, context) => {
...
});
The debug log contained the following error message:
fieldViolations=[field=event_trigger, description=Expected value chats to match regular expression [^/]+/[^/]+(/[^/]+/[^/]+)*]]
And that's when I realized that chats is not a document but a collection. I changed the path to that of the collection and everything worked fine.
EDIT:
To view more logs you can also try:
firebase functions:log
or
firebase functions:log --only <FUNCTION_NAME>
Link to documentation.
I had the same issue with Firestore ,my problem was that the path to the document was bad. I had a slash at the beginning and the end of the path to my document like I used to do with Firebase Realtime Database path.
Hope it helps someone.
Just close whatever IDE you're using and then reopen it. Then on node redeploy your functions. This should resolve the issue.
I got this error as well, I had the problem that a dependency was missing in the package.json file.
By running
firebase --debug deploy it returned an error on the user code.
firebase functions:log gave then the specifics, that a package was not included.
I deleted yarn.lock then error goes away. I think package-lock.json and yarn.lock should not exist together.
Check your json modules dependencies inside functions folder.
There's an specific json package there.
If some module you are including in the project and is not there (in json) you probably will have the error mentioned.
To install just run:
npm install <module> --save
or
yarn add <module> --save
and then run your deploy again:
firebase deploy --only functions
In my case firebase deploy failed with the error "Error: Functions did not deploy properly." and no further explanation. I noticed that no functions could be deployed even the ones I didn't touch.
So I checked for dependencies and I found that a library was not present in the "package.json".
So I execute this command:
cd functions && rm -rf node_modules && rm package-lock.json && npm install && npm install [specific Librairy not in package.json] && firebase deploy
After that the deployment succeeded and the missing dependency appeared in the package.json
Recently Firebase lets you use Functions only if you have the Blaze-Pay as you go plan. So you cannot deploy functions as well, and you will get this same error message without any further clarifications.
Mine was about;
"Function deployment failed because the billing account is not available."
So I had pending payment, after paying, it worked as expected.
I was running into the same generic error message, and ended up running (as mentioned in this question):
firebase --debug deploy --only functions:[functionName]
This revealed the actual issue (my project did not have a default GCP resource location, fix for this described here: Firebase Project Initialization Error: Cloud resource location is not set for this project)
Once I set the GCP resource location, function deployed without issue!
In my case, After a long time of searching, I found the reason to be that I had disabled billing for the project for debugging.
It worked fine now after I enabled it in the Google cloud console.
It's really sad how firebase can't show any useful error message to suggest the problem. I found this after many trials.
I faced a similar problem, but I was using Typescript.
It was basically targeting a non-supported javascript version (ES2020). I changed the tsconfig.json and it deployed normally
"lib": [
"es2019",
"es2020.bigint",
"es2020.string",
"es2020.symbol.wellknown"
],
"module": "commonjs",
"target": "es2019"
After getting the above deploy error, I edited the index.js file and changed the name of the function from "helloWorld" to "heyWorld" and suddenly the firebase deploy command worked.
If anyone gets here trying to deploy ssr functions in angular universal with firebase, it is because firebase is not included in your functions.
1.) cd functions
2.) npm i firebase#latest
3.) npm run deploy
4.) cd ..
5.) now when you run ng deploy it should work correctly... The key here is to add firebase, and deploy with npm run deploy first...
try to add this
"runtime": "nodejs12"
in your firebase,json
example :
"functions": {
"source": ".",
"ignore": [
".firebase/**",
"**/node_modules/**",
"**/public/**",
".firebaserc",
"firebase.json",
"postcss.config.js",
"README.md",
"tailwind.config.js"
],
"runtime": "nodejs12"
}
was with the same error, I ended up solving it by updating package.json
from:
"engines": {
"node": "12"
},
to:
"engines": {
"node": "14"
},
$ in path causes Error: Functions did not deploy properly.
before:
`export const newMessage = functions.firestore.document('chats/${chatId}/messages/${messageId}').onCreate(handleNewMessage())`
after:
`export const newMessage = functions.firestore.document('chats/{chatId}/messages/{messageId}').onCreate(handleNewMessage())`
In my case, the location for the Firestore was not correctly set. From the Functions Documentation:
By default, functions run in the us-central1 region.
In my case, Firestore was set up on a different location. You can find this under Project Settings, at Default GCP resource location.
To fix it, simply make the following change:
// Before
functions.firestore.document("...").onCreate(...)
// After
functions.region("asia-east2").firestore.document("...").onCreate(...)
Follow the steps below:
Deploy with debug enabled:
firebase --debug deploy
You will see the error printed in your console.
In most cases it is something similar to the line below:
npm install before continuing.\nnpm ERR! \nnpm ERR! \nnpm ERR! Invalid: lock file's body-parser#1.19.0 does not satisfy body-parser#~1.0.1\nnpm ERR!
If the error is similar to "lock file's body-parse" in 1) above:
Go to the views directory in your project and edit the dependencies section in your package.json file as below:
Change the body-parser version to the latest version shown in the error printed in 1) above. In my case it was from body-parser#~1.0.1 to body-parser#~1.19.0
Run: npm install
Re-deploy with: firebase deploy
This should work.
If you get a 403 error from your hosting URL after re-deploying, your CLI version could be out of date:
Login to you google cloud account and go your the google cloud console.
Delete your Cloud Functions
Update Firebase CLI using: npm install -g firebase-tools
Re-deploy: firebase deploy
My firebase couldnt find the modules firebase-functions and firebase-admin on deploy because I wrote them in devDependencies instead of just dependencies. But after it ... I still had an issue. But this solved it for me: https://github.com/nuxt/nuxt.js/issues/2714#issuecomment-423048343.
Just notice node 8 as engine object in your function's folder package.json and add the babel snippet in your nuxt config.
I had same problem with Firebase project deployment. Then figure out error and find that some module paths are cause problem. Then i changed the path of that module.
To try redeploying those functions, run:
firebase deploy --only functions:api,functions:createScream
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
The error shows that could not find modules.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module (../key/your secret key.json) '
Then i changed the path of my secret key that is required for login credentials and put it in different folder. Then run firebase deploy.
That work for me.
I had the same problem. The problem came from the fact that I had an index.js file and package.json file in the root folder and, after running the firebase functions init command, also an index.js and package.json in the functions folder. The dependencies are only listed in the package.json file in the root folder, not in the functions folder. I copied the dependencies to the package.json file in the functions folders and everything worked like a charm.
Deleting the build functions folder worked to me
firebase functions:log
This allowed me to find out the problem in my case: one of the packages was not listed among the dependencies in package.json
This worked for me today: Delete Function and Redeploy.
It happened the same to me but unfortunately I had not any error with --debug.
I then deleted all my deployed functions in the firebase console and
cd functions
rm -rf node_modules
npm install
firebase deploy --only functions
and it worked like magic.
I got the same error
Functions were working in emulator, but couldn't be deployed.
When I deployed functions using debug, I got no more specific info.
Then I found out, that my IDE accidentally imported lib (that I wasn't even using) from parent folder where is my Svelte project located.
Removing that import fixed my error, obviously.
I deleted the recently added 3rd party library (from package/package-lock.json as well). And checked the name of the function to not be a duplicate.
This worked for me.
If u are using SSR you need declare your node version In my case my node version is 14 and firebase was deploying with 10.0 I set this config on angular.json
"functionsNodeVersion": 14
"serve-ssr": {
"builder": "#nguniversal/builders:ssr-dev-server",
"options": {
"browserTarget": "Rioja-web:build",
"serverTarget": "Rioja-web:server"
},
"configurations": {
"production": {
"browserTarget": "Rioja-web:build:production",
"serverTarget": "Rioja-web:server:production"
}
}
},
"prerender": {
"builder": "#nguniversal/builders:prerender",
"options": {
"browserTarget": "Rioja-web:build:production",
"serverTarget": "Rioja-web:server:production",
"routes": [
"/"
]
},
"configurations": {
"production": {}
}
},
"deploy": {
"builder": "#angular/fire:deploy",
"options": {
"ssr": true,
"functionsNodeVersion": 14
}
}
}
I had the same problem.
updating node engine to 16 in package.json solved the issue.
My nodejs local version was 16.
{
...
"engines": {
"node": "16"
},
"main": "lib/index.js",
"dependencies": { ... }
}

Default options for launching meteor

I'm using Meteor.Settings to access secrets stored within a settings.json.
Everything works fine using meteor --settings settings.json, but ideally i'd like to just call meteor and have it automatically pick up the settings. Is there a meteor way of specifying default options to the meteor cli? E.g. a file like meteor.opts that would contain flags?
That is what the --settings command is for. I can't see the issue with just running with the --settings command

Deployment with Password using Linux in Meteor?

How to deploy a app with password in meteor using linux. It's deploy good when with out set password.But i need to deploy app with password in meteor. I did but gets some error messages i didn't understand the following messages.So please see the below deployment process and suggestions me what to do?
[root#localhost myapp]# meteor deploy myapp.meteor.com --password
deploy: the --password option needs a value.
Try 'meteor help deploy' for help.
[root#localhost myapp]# meteor deploy myapp.meteor.com 123456
deploy: too many arguments.
Usage: meteor deploy <site> [--settings settings.json] [--debug] [--delete]
Deploys the project in your current directory to Meteor's servers.
You can deploy to any available name under 'meteor.com'
without any additional configuration, for example,
'myapp.meteor.com'. If you deploy to a custom domain, such as
'myapp.mydomain.com', then you'll also need to configure your domain's
DNS records. See the Meteor docs for details.
The --settings flag can be used to pass deploy-specific information to
the application. It will be available at runtime in Meteor.settings, but only
on the server. If the object contains a key named 'public', then
Meteor.settings.public will also be available on the client. The argument
is the name of a file containing the JSON data to use. The settings will
persist across deployments until you again specify a settings file. To
unset Meteor.settings, pass an empty settings file.
The --delete flag permanently removes a deployed application, including
all of its stored data.
Options:
--delete, -D permanently delete this deployment
--debug deploy in debug mode (don't minify, etc)
--settings set optional data for Meteor.settings
--star a star (tarball) to deploy instead of the current Meteor app
[root#localhost myapp]#
Perhaps you should use both command and option:
meteor deploy myapp.meteor.com --password 123456

Resources