Hi Strapi Community,
Has anyone successfully deployed Strapi V4 to GCP App Engine?
I followed the instructions in the deployment guide but I am having no luck, I keep hitting the server wasn’t able to start properly error on GCP.
Below listed are few issues I am facing.
- The guide describes that I need to make a database.js file in ./config/env/production/ directory. However I noticed that the database file in the production directory is ignored, and database file in ./config/ is referenced (dev database.js).
./config/database.js
module.exports = ({ env }) => ({
connection: {
client: 'postgres',
connection: {
host: env('DATABASE_HOST', '0.0.0.0'),
port: env.int('DATABASE_PORT', 5433),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'secret'),
ssl: env.bool('DATABASE_SSL', false),
},
},
});
./config/env/production/database.js
module.exports = ({ env }) => ({
connection: {
client: 'postgres',
connection: {
host: `/cloudsql/${env('INSTANCE_CONNECTION_NAME')}`,
database: env('DATABASE_NAME'),
user: env('DATABASE_USER'),
password: env('DATABASE_PASSWORD'),
},
},
});
the ./app.yaml file
service: strapi
runtime: nodejs16
instance_class: F2
env_variables:
HOST: '0.0.0.0'
NODE_ENV: 'production'
DATABASE_NAME: 'strapi'
DATABASE_USERNAME: 'strapi'
DATABASE_PASSWORD: 'secret'
INSTANCE_CONNECTION_NAME: 'instance-name-on-gcp-postgres-db'
beta_settings:
cloud_sql_instances: 'instance-name-on-gcp-postgres-db'
- Due to above, I replaced the references in dev database.js with the production version.
- the latest error is showing the following -
"GET / HTTP/1.1" 500
2022-09-13 20:01:31 strapi[20220913t205411] dev database file called!
2022-09-13 20:01:33 strapi[20220913t205411] [2022-09-13 20:01:33.395] debug: ⛔️ Server wasn't able to start properly.
2022-09-13 20:01:33 strapi[20220913t205411] [2022-09-13 20:01:33.397] error: no PostgreSQL user name specified in startup packet
2022-09-13 20:01:33 strapi[20220913t205411] error: no PostgreSQL user name specified in startup packet
2022-09-13 20:01:33 strapi[20220913t205411] at Parser.parseErrorMessage (/workspace/node_modules/pg-protocol/dist/parser.js:287:98)
2022-09-13 20:01:33 strapi[20220913t205411] at Parser.handlePacket (/workspace/node_modules/pg-protocol/dist/parser.js:126:29)
2022-09-13 20:01:33 strapi[20220913t205411] at Parser.parse (/workspace/node_modules/pg-protocol/dist/parser.js:39:38)
2022-09-13 20:01:33 strapi[20220913t205411] at Socket.<anonymous> (/workspace/node_modules/pg-protocol/dist/index.js:11:42)
2022-09-13 20:01:33 strapi[20220913t205411] at Socket.emit (node:events:527:28)
2022-09-13 20:01:33 strapi[20220913t205411] at Socket.emit (node:domain:475:12)
2022-09-13 20:01:33 strapi[20220913t205411] at addChunk (node:internal/streams/readable:315:12)
2022-09-13 20:01:33 strapi[20220913t205411] at readableAddChunk (node:internal/streams/readable:289:9)
2022-09-13 20:01:33 strapi[20220913t205411] at Socket.Readable.push (node:internal/streams/readable:228:10)
2022-09-13 20:01:33 strapi[20220913t205411] at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
Regardless how I got here trying to patch the issues, the instructions on the guide page doesn’t work, even on a fresh install.
[details="System Information"]
- **Strapi Version**: 4.3.8
- **Operating System**: Mac Os 12.5
- **Database**: Postgres 13
- **Node Version**: * v14.15.5
- **NPM Version**: 6.14.11
- **Yarn Version**: 1.22.18
[/details]
---