8000 Update Google Cloud Platform deployment documentation for strapi v4 by techhtml · Pull Request #647 · strapi/documentation · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update Google Cloud Platform deployment documentation for strapi v4 #647

New iss 8000 ue

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

Merged
merged 4 commits into from
Jan 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ Create another database, named `strapi` for example. It may be useful to delete

Create the `app.yaml` file in the project root.

Add `app.yaml` to `.gitignore`.

The instance identifier looks like `myapi-123456:europe-west1:myapi`.

The `myapi-123456` part is the project identifier. (The number is automatically added to short project names).
Expand All @@ -106,15 +104,15 @@ The following is an example config for `Standard Environment` or `Flexible Envir
::: tab Standard Environment

```yaml
runtime: nodejs14
runtime: nodejs16

instance_class: F2

env_variables:
HOST: '0.0.0.0'
NODE_ENV: 'production'
DATABASE_NAME: 'strapi'
DATABASE_USERNAME: 'postgres'
DATABASE_USER: 'postgres'
DATABASE_PASSWORD: '<password>'
INSTANCE_CONNECTION_NAME: '<instance_identifier>'

Expand All @@ -135,7 +133,7 @@ env_variables:
HOST: '0.0.0.0'
NODE_ENV: 'production'
DATABASE_NAME: 'strapi'
DATABASE_USERNAME: 'postgres'
DATABASE_USER: 'postgres'
DATABASE_PASSWORD: '<password>'
INSTANCE_CONNECTION_NAME: '<instance_identifier>'

Expand All @@ -150,18 +148,25 @@ beta_settings:
Create `.gcloudignore` in the project root.

```
app.yaml
.gcloudignore
.git
.gitignore
node_modules/
#!include:.gitignore
!.env
```

In the case of Strapi, the admin UI will have to be re-built after every deploy,
and so we don't deploy local build artifacts, cache files and so on by including
the `.gitignore` entries.

### Adding `.gitkeep` to database folder
Google App Engine does not give `mkdir` permissions and the `database/migrations` folder is required for deployments. Make sure `git` keeps track of the `database/migrations` folder by adding a `.gitkeep` file to the folder. Use the following command:

```bash
touch .gitkeep
```

### Configure the database

The `PostgreSQL` database will need the `pg` package.
Expand All @@ -170,26 +175,19 @@ The `PostgreSQL` database will need the `pg` package.
yarn add pg
```

[Google App Engine requires](https://cloud.google.com/sql/docs/postgres/connect-app-engine) to connect to the database using the unix socket path, not an IP and port.

Edit `database.js`, and use the socket path as `socketPath`.

`Path: ./config/env/production/database.js`.
Adding the production database configuration for connect to GCP SQL.

```js
// path: ./config/env/production/database.js

module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'postgres',
socketPath: `/cloudsql/${env('INSTANCE_CONNECTION_NAME')}`,
connection: {
client: 'postgres',
connection: {
host: `/cloudsql/${env('INSTANCE_CONNECTION_NAME')}`,
database: env('DATABASE_NAME'),
username: env('DATABASE_USERNAME'),
user: env('DATABASE_USER'),
password: env('DATABASE_PASSWORD'),
},
options: {},
},
},
});
Expand Down
0