I'm trying to deploy strapi on google cloud app engine (standard env) but I keep getting a 500 server error. I googled all over but no guides have been written on how to successfully deploy strapi on AE.
I tried the suggestions on this thread: https://github.com/strapi/strapi/issues/2146
So I have:
the gcp-build script to install dependencies
an entrypoint in app.yaml to start strapi
my database.json and server.json in strapi are updated
But it does not seem to work for me. I keep getting the following error:
I tried googling that error "app/invalid" but I can't seem to find anything about that.
I also gave the flex env a spin but that failed as well (without a proper error).
This is my app.yaml file:
runtime: nodejs10
instance_class: F2
service: admin
entrypoint: node_modules/strapi/bin/strapi.js
env_variables:
DATABASE_HOST: "host"
DATABASE_PORT: 27017
DATABASE_NAME: "db"
DATABASE_USERNAME: "name"
DATABASE_PASSWORD: "pw"
DATABASE_SRV: true
DATABASE_AUTHENTICATION_DATABASE: "admin"
DATABASE_SSL: true
NODE_ENV: "production"
PORT: 1337
This is my package.json (important parts):
...
"scripts": {
"strapi": "node_modules/strapi/bin/strapi.js",
"gcp-build": "node node_modules/strapi/lib/utils/post-install.js && cd admin && npm run setup"
}
...
"engines": {
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
production database.json:
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "strapi-hook-mongoose",
"settings": {
"client": "mongo",
"host": "host",
"port": 27017,
"database": "db",
"username": "name",
"password": "pw",
"srv": true
},
"options": {
"authenticationDatabase": "admin",
"ssl": true
}
}
}
}
And finally this is my server.json file:
{
"host": "https://admin-dot-ootje-website.appspot.com",
"port": 1337,
"production": true,
"proxy": {
"enabled": false
},
"autoReload": {
"enabled": false
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false
}
}
I would expect that this works from the getting started guides in AE but it would seem I'm missing something. Does someone know what that error means? Did someone manage to already deploy strapi on AE?
If I get it working I'd like to add it to strapi docs or medium post for other people to find it easier than I did :)
Thanks in advance!
I think your problem provide from server.json file.
This configuration works on my side :
{
"host": "localhost",
"port": "${process.env.PORT || 1337}",
"production": true,
"proxy": {
"enabled": false
},
"autoReload": {
"enabled": false
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false
}
}
I'm working on a new configuration file in order to have the auth provider working... and some other features. But this first version is working for me.
I keep you update of my search if you need.
## Update 1 ##
I found the good configuration for GCP in production mode.
I share it if anyone else need it :
{
"host": "localhost",
"port": "${process.env.PORT || 1337}",
"production": true,
"proxy": {
"enabled": true,
"ssl": true,
"host": "[project-name].appspot.com",
"port": 443
},
"autoReload": {
"enabled": false
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false
}
}
I use flexible environment on GCP, but this will work in standard mode I think.
Thanks,
Related
I am trying to connect a MongoDB URI to the strapi backend.
I am able to connect with the main URL but when I created a .env.development variable, I am not able to connect to the database.
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "mongoose",
"settings": {
"uri": "${process.env.DATABASE_URI || ''}"
},
"options": {
"ssl": true
}
}
}
}
Ok, new plan.
try that :
npm install --save dotenv
require('dotenv').config()
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "mongoose",
"settings": {
"uri": `${process.env.DATABASE_URI || ''}`
},
"options": {
"ssl": true
}
}
}
}
I am new to programming and strapi. Just want to share i have problem with deploying to heroku with the same problem. I fix it with this:
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "mongoose",
"settings": {
"uri": "${process.env.DATABASE_URI}",
"database": "${process.env.DATABASE_NAME}"
},
"options": {
"ssl": true
}
}
}
}
If you are deploying to heroku please check the environment variables. When I set environment variables using heroku cli it does not save the whole string. I have to copy and paste to the heroku website directly.
I've created a Strapi cms instance connecting to a remote Atlas db.
Now I have to create some more environments so I'm trying to change the development database uri.
but changing the uri in config/environments/development/database.json has. no effect.
I'm:
Changing the value
Running strapi build
Running strapi develop
all the old content is still there
Not everything is stored in the database, model settings are stored in files
You should change the values of the file:
Path: ./config/environments/(development|production)/database.json.
example:
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "strapi-mongoose",
"settings": {
"client": "mongo",
"host": "ds125048.mlab.com",
"port": "25048",
"database": "myapp-development",
"username": "myusername",
"password": "mypassword"
},
"options": {
"authenticationDatabase": "myapp-development",
"ssl": false
}
}
}
}
Then re-deploy to your app
more details
I am using eureka-js-client to register on Eureka, this works fine when deployed locally, however when I deploy on the AWS, the "hostName" value set is replaced with empty value.
Since I set ingressUrl as hostName, how to stop eureka-js-client not to touch the "hostName" ?
eureka-js-client version - "4.2.0"
Eureka version - 1.9.2, (SpringBoot 2.x)
Here's portion of Eureka config looks like:
"instance": {
"app": "<MyApp>",
"hostName": "<MyHostname>", // I dont want this to be overwritten by AWS-meta-data
"ipAddr": "<MyIp>",
"vipAddress": "<MyVip>",
"secureVipAddress": "<address>",
"homePageUrl": "<url>",
"healthCheckUrl": "<url>",
"statusPageUrl": "<url>",
"instanceId": "<InstanceId>"
"port": {
"$": 80,
"#enabled": false
},
"securePort": {
"$": 443,
"#enabled": true
},
"dataCenterInfo": {
"#class": "com.netflix.appinfo.AmazonInfo",
"name": "Amazon"
},
},
"useLocalMetadata": true
}
This is what I end up doing,
"instance": {
"app": "<MyApp>",
"hostName": "<MyHostname>", // I dont want this to be overwritten by AWS-meta-data
"ipAddr": "<MyIp>",
"vipAddress": "<MyVip>",
"secureVipAddress": "<address>",
"homePageUrl": "<url>",
"healthCheckUrl": "<url>",
"statusPageUrl": "<url>",
"instanceId": "<InstanceId>"
"port": {
"$": 80,
"#enabled": false
},
"securePort": {
"$": 443,
"#enabled": true
},
"dataCenterInfo": {
"#class": "com.netflix.appinfo.AmazonInfo",
"name": "Amazon"
},
"eureka": {
"serviceUrls": {
"default": "<eureka_url>"
},
"fetchMetadata" : false, #turn this off, and set your own metadata, you can use AWSmetada.js present in eurek-client-js
"registerWithEureka" : true
}
}
for more details see here: https://www.npmjs.com/package/eureka-js-client#configuring-for-aws-environments
I just got started using strapi framework and I would like to use mLab as my mongoDB database, so I go to configure strapi and fill the following details:
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "strapi-mongoose",
"settings": {
"client": "mongo",
"host": "localhost",
"port": 27017,
"database": "development",
"username": "",
"password": ""
},
"options": {}
}
}
}
The details I get from mLab are:
mongodb://myUsername:myPassword#ds047891.mlab.com:41365/myDatabase
Here is my final config:
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "strapi-mongoose",
"settings": {
"client": "mongo",
"host": "ds047891.mlab.com",
"port": 41365,
"database": "myDatabase",
"username": "myUsername",
"password": "myPassword"
},
"options": {}
}
}
}
When I try to start strapi, I get the following error:
DEBUG (2748 on DESKTOP-HAL1ATE): Server wasn't able to start properly.
ERROR (2748 on DESKTOP-HAL1ATE): (hook:mongoose) takes too long to load
I think that I did not setup my configuration right, but I can't pinpoint where the problem is. I hope someone could, thanks.
I am Pierre, on of the creators of Strapi. I tried with the following configuration and it worked well:
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "strapi-mongoose",
"settings": {
"client": "mongo",
"host": "ds135777.mlab.com",
"port": "35777",
"database": "myDatabase",
"username": "myUsername",
"password": "myPassword"
},
"options": {}
}
}
}
Our configurations files look quiet similar.
What file did you updated (/config/environment/development/database.json or /config/environment/production/database.json)?
Are you sure you entered the correct username and password? Did you try to login to your MongoDB instance through the command line mongo ds135777.mlab.com:35777/myDatabase -u <dbuser> -p <dbpassword>?
UPDATE
In version >= 3 for mlab don't forget to specify authenticationDatabase
"options": {
"authenticationDatabase": "your_mlad_database_name",
"ssl": false
}
I am trying to install and run this node.js chat: https://github.com/dual3nigma/Mejorando.la-Chat.
When I type "npm install" and "node server" it starts, but with an Express error. I think the reason is in the config.json file.
This is my config.json file. I've only changed the db name and port of the config.sample.json file and added my twitter / facebook keys:
{
"port": 721,
"host": "localhost",
"db": {
"name": "V1chatCCI"
},
"twitter": {
"consumerKey": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
"consumerSecret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"facebook": {
"appId": "XXXXXXXXXXXXXXXXXXXXXXXX",
"appSecret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"session": {
"secret": "",
"key": ""
},
"cookie": {
"secret": ""
},
"secure": false,
"loginsecure": false,
"key": "",
"cert": "",
"sentry": "dsn"
}
What do I need to put in the session secret/key section? The error on localhost:721 is:
Express
500 Error: secret option required for sessions
You should be able to put anything in those sections, as they're used used internally by express handling sessions. Any values (even just random strings) should fix your problem.