From 2e9e8b80896446b2b6276a48965868844b130546 Mon Sep 17 00:00:00 2001 From: Gambhiro Date: Fri, 24 Jan 2020 19:44:34 +0000 Subject: [PATCH 1/8] deploy to google app engine --- docs/3.0.0-beta.x/guides/deployment.md | 377 +++++++++++++++++++++++++ 1 file changed, 377 insertions(+) diff --git a/docs/3.0.0-beta.x/guides/deployment.md b/docs/3.0.0-beta.x/guides/deployment.md index d6e6ce8fe3..106a3f83db 100644 --- a/docs/3.0.0-beta.x/guides/deployment.md +++ b/docs/3.0.0-beta.x/guides/deployment.md @@ -1622,3 +1622,380 @@ heroku open Like with project updates on Heroku, the file system doesn't support local uploading of files as they will be wiped when Heroku "Cycles" the dyno. This type of file system is called [ephemeral](https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem), which means the file system only lasts until the dyno is restarted (with Heroku this happens any time you redeploy or during their regular restart which can happen every few hours or every day). Due to Heroku's filesystem you will need to use an upload provider such as AWS S3, Cloudinary, or Rackspace. You can view the documentation for installing providers [here](../plugins/upload.md#install-providers) and you can see a list of providers from both Strapi and the community on [npmjs.com](https://www.npmjs.com/search?q=strapi-provider-upload-&page=0&perPage=20). + +## Google App Engine +### New Strapi project (optional) + +``` +yarn create strapi-app --quickstart +``` + +The setup: + +- Creates the initial files, configured to use `sqlite` database +- Runs `strapi build "--no-optimization"` to build the admin UI +- Runs `strapi develop`, which starts the app in `development` mode +- Open a the admin user registration form in the browser + +``` +: One more thing... +: Create your first administrator 💻 by going to the administration panel at: +: http://localhost:1337/admin +``` + +Setup an admin user. This user will be only relevant in local development. + +The `sqlite` database is created at `.tmp/data.db`. + +Login, but don't add content types yet. Close the browser. Quit the running app. + +### Initial commit (optional) + +This may be a good point to create and empty root commit and add the files in their initial state. + +``` +git init +git commit -m initial --allow-empty +git add -A . +git commit -m first +``` + +### Install the Cloud SDK CLI tool + +https://cloud.google.com/sdk/ + +### New App Engine project + +Create a new [App Engine](https://console.cloud.google.com/appengine/) project. + +Select the region, such as `europe-west`. + +Language: Node JS + +Environment: Standard + +The Flexible enviroment is also available, but incurs more cost. + +Create the project. Take note of the instance identifier, which is in the form of `::`. + +and see if `gcloud` lists it: + +``` +gcloud projects list +``` + +Run `init` to authenticate the cli, and select current cloud project. + +``` +gcloud init +``` + +### Create the database (PostgreSQL) + +Create the [Cloud SQL database](https://cloud.google.com/sql/docs/postgres/create-manage-databases) which the app is going to use. + +Take note of the user name (default is `postgres'`) and password. + +The first database will be created with name `default`. This cannot be deleted. + +Create another database, named `strapi`. It may be useful to delete and and re-create this while you are experimenting with the application setup. + +### Create app.yaml and .gcloudignore + +Create the `app.yaml` file in the project root. + +Add `app.yaml` to `.gitignore`. + +The instance identifier looks like `myapi-123456:europe-west1:myapi`. + +``` yaml +runtime: nodejs10 + +instance_class: F2 + +env_variables: + HOST: '.appspot.com' + NODE_ENV: 'production' + DATABASE_NAME: 'strapi' + DATABASE_USERNAME: 'postgres' + DATABASE_PASSWORD: '' + INSTANCE_CONNECTION_NAME: '' + +beta_settings: + cloud_sql_instances: '' +``` + +Create `.gcloudignore` in the project root. + +``` +.gcloudignore +.git +.gitignore +node_modules/ +#!include:.gitignore +``` + +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. + +### Configure the database + +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.json`, and use the socket path as `host`. + +``` +config/environments/production/database.json +``` + +``` json +{ + "defaultConnection": "default", + "connections": { + "default": { + "connector": "bookshelf", + "settings": { + "client": "postgres", + "host": "/cloudsql/${process.env.INSTANCE_CONNECTION_NAME}", + "database": "${process.env.DATABASE_NAME}", + "username": "${process.env.DATABASE_USERNAME}", + "password": "${process.env.DATABASE_PASSWORD}" + }, + "options": {} + } + } +} +``` + +Edit `server.json` to pick up the deployed hostname from the `HOST` variable in `app.yaml`. + +``` +config/environments/production/server.json +``` + +``` json +{ + "host": "${process.env.HOST}", + "port": "${process.env.PORT || 1337}", + "production": true, + "proxy": { + "enabled": false + }, + "cron": { + "enabled": false + }, + "admin": { + "autoOpen": false + } +} +``` + +### Auto-build after deploy + +After deployment, the admin UI has to be re-built. This generates the contents of the `build` folder on the server. + +In `package.json`, add the `gcp-build` command to `scripts`: + +``` json +{ + "scripts": { + "gcp-build": "strapi build" + } +} +``` + +### Deploy + +``` +gcloud app deploy app.yaml --project myapi-123456 +``` + +Watch the logs: + +``` +gcloud app logs tail --project=myapi-123456 -s default +``` + +Open the admin page and register and admin user. + +``` +https://myapp-123456.appspot.com/admin/ +``` + +### Creating new content types + +Open in develoment mode locally. + +``` +yarn develop +``` + +Content Type Builder > Create new content type + +``` +model name: book +title: text +description: rich text +``` + +Save. + +``` +model name: author +name: text +``` + +Save. + +Open the `Book` type, add a relation: + +``` +book has and belongs to many authors +``` + +Save. + +Logout, quit the quit running app. + +The `api/` folder now includes `book` and `author`. + +Deploy. + +``` +gcloud app deploy app.yaml --project myapi-123456 +``` + +It might say `Uploading 0 files`, but if you look the service sources, you should see the new version. + +App Engine > Services > myapi (2 versions) > Source + +The contents of the `api` folder were deployed, you can inspect the `book` and `author` folders. + +Visit and reload the app URL so that the new version is started up. + +https://myapi-123456.appspot.com + +Login to the admin UI. + +https://myapi-123456.appspot.com/admin + +Open Books and Authors, add records and create relations. + +If you haven't enabled the permission yet, the API will respond with `403 Forbidden`. + +https://myapi-123456.appspot.com/books + +Update Permissions: + +Roles and Permissions > Public + +Enable `count`, `find`, `findone` for `author` and `book`. + +https://myapi-123456.appspot.com/books + +Should returns the JSON data. + +### File uploading to Google Cloud Storage + +https://github.com/Lith/strapi-provider-upload-google-cloud-storage + +``` +yarn add strapi-provider-upload-google-cloud-storage +``` + +Deploy so that the server app includes the dependency from =package.json=. + +Create a Google service account key. + +https://console.cloud.google.com/apis/credentials/serviceaccountkey + +Save the JSON credentials file. + +Plugins > File Upload > Settings > Production tab + +By default localhost is selected. Select the Google Cloud Storage plugin. + +Copy the JSON key and set the regions. + +Cloud Console > Storage > Browser + +Copy the bucket name to the plugin settings, the default is the app ID, such as `myapi-123456.appspot.com`. + +Save. + +In the Strapi Admin UI: + +Roles & Permissions > Public > Upload + +Enable `count` and `findone`. + +https://myapi-123456.appspot.com/upload/files/count + +Should return `{"count":"0"}`. + +Files Upload > upload a file. + +`/files/count` should new return `1`. + +Logout. + +Start the local dev server and login to the Admin UI. + +``` +yarn develop +``` + +Add a Media field to the Book type. + +Content Types > Book > Add another field > Media field + +``` +name: downloads +Multiple media +``` + +Save. + +Deploy, and login to the server Admin UI. + +Open one of the books and add downloads. Save. + +The `/books` api should display the associated files. + +https://myapi-123456.appspot.com/books + +### Success! + +Read to go! + +### Post-setup configuration + +**CORS** + +CORS is enabled by default, allowing `*` origin. You may want to limit the allowed origins. + +``` +config/environments/production/security.json +``` + +**Changing the admin url.** + +``` +config/environments/production/server.json +``` + +``` json +{ + "admin": { + "path": "/dashboard" + } +} +``` + From fd1e553645cc7dc53d5c52b917b8f3baa27ad374 Mon Sep 17 00:00:00 2001 From: Gambhiro Date: Sat, 25 Jan 2020 07:20:30 +0000 Subject: [PATCH 2/8] edit --- docs/3.0.0-beta.x/guides/deployment.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/3.0.0-beta.x/guides/deployment.md b/docs/3.0.0-beta.x/guides/deployment.md index 106a3f83db..741ad35ec9 100644 --- a/docs/3.0.0-beta.x/guides/deployment.md +++ b/docs/3.0.0-beta.x/guides/deployment.md @@ -1624,7 +1624,16 @@ Like with project updates on Heroku, the file system doesn't support local uploa Due to Heroku's filesystem you will need to use an upload provider such as AWS S3, Cloudinary, or Rackspace. You can view the documentation for installing providers [here](../plugins/upload.md#install-providers) and you can see a list of providers from both Strapi and the community on [npmjs.com](https://www.npmjs.com/search?q=strapi-provider-upload-&page=0&perPage=20). ## Google App Engine -### New Strapi project (optional) + +In this guide we are going to: + +- create a new Strapi project +- configure PostgreSQL for the production enviroment +- deploy the app to Google App Engine + - (using Standard Environment, but Flexible would be possible and probably easier) +- add the [Google Cloud Storage file uploading plugin](https://github.com/Lith/strapi-provider-upload-google-cloud-storage) by @Lith + +### New Strapi project ``` yarn create strapi-app --quickstart @@ -1649,7 +1658,7 @@ The `sqlite` database is created at `.tmp/data.db`. Login, but don't add content types yet. Close the browser. Quit the running app. -### Initial commit (optional) +### Initial commit This may be a good point to create and empty root commit and add the files in their initial state. From 66494732107c2039c18d52a76cb7d6f2750b794e Mon Sep 17 00:00:00 2001 From: Gambhiro Date: Sat, 25 Jan 2020 07:21:25 +0000 Subject: [PATCH 3/8] link --- docs/3.0.0-beta.x/guides/deployment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/3.0.0-beta.x/guides/deployment.md b/docs/3.0.0-beta.x/guides/deployment.md index 741ad35ec9..7efd4c131c 100644 --- a/docs/3.0.0-beta.x/guides/deployment.md +++ b/docs/3.0.0-beta.x/guides/deployment.md @@ -1631,7 +1631,7 @@ In this guide we are going to: - configure PostgreSQL for the production enviroment - deploy the app to Google App Engine - (using Standard Environment, but Flexible would be possible and probably easier) -- add the [Google Cloud Storage file uploading plugin](https://github.com/Lith/strapi-provider-upload-google-cloud-storage) by @Lith +- add the [Google Cloud Storage file uploading plugin](https://github.com/Lith/strapi-provider-upload-google-cloud-storage) by [@Lith](https://github.com/Lith) ### New Strapi project From 1c466cd056083d785338ab8f4d160e88caf2626e Mon Sep 17 00:00:00 2001 From: Gambhiro Date: Thu, 6 Feb 2020 21:04:39 +0000 Subject: [PATCH 4/8] typos and clean up --- docs/3.0.0-beta.x/guides/deployment.md | 111 +++++++++++++++---------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/docs/3.0.0-beta.x/guides/deployment.md b/docs/3.0.0-beta.x/guides/deployment.md index 7efd4c131c..6ea3181e1a 100644 --- a/docs/3.0.0-beta.x/guides/deployment.md +++ b/docs/3.0.0-beta.x/guides/deployment.md @@ -1627,32 +1627,38 @@ Due to Heroku's filesystem you will need to use an upload provider such as AWS S In this guide we are going to: -- create a new Strapi project -- configure PostgreSQL for the production enviroment -- deploy the app to Google App Engine - - (using Standard Environment, but Flexible would be possible and probably easier) -- add the [Google Cloud Storage file uploading plugin](https://github.com/Lith/strapi-provider-upload-google-cloud-storage) by [@Lith](https://github.com/Lith) +- Create a new Strapi project +- Configure PostgreSQL for the production enviroment +- Deploy the app to Google App Engine +- Add the [Google Cloud Storage file uploading plugin](https://github.com/Lith/strapi-provider-upload-google-cloud-storage) by [@Lith](https://github.com/Lith) ### New Strapi project -``` -yarn create strapi-app --quickstart +:::: tabs + +::: tab yarn + +Use **yarn** to install the Strapi project (**recommended**). [Install yarn with these docs](https://yarnpkg.com/lang/en/docs/install/) + +```bash +yarn create strapi-app my-project --quickstart ``` -The setup: +::: -- Creates the initial files, configured to use `sqlite` database -- Runs `strapi build "--no-optimization"` to build the admin UI -- Runs `strapi develop`, which starts the app in `development` mode -- Open a the admin user registration form in the browser +::: tab npx -``` -: One more thing... -: Create your first administrator 💻 by going to the administration panel at: -: http://localhost:1337/admin +Use **npm/npx** to install the Strapi project + +```bash +npx create-strapi-app my-project --quickstart ``` -Setup an admin user. This user will be only relevant in local development. +::: + +:::: + +When the setup completes, register an admin user using the form which opens in the browser. This user will be only relevant in local development. The `sqlite` database is created at `.tmp/data.db`. @@ -1660,18 +1666,18 @@ Login, but don't add content types yet. Close the browser. Quit the running app. ### Initial commit -This may be a good point to create and empty root commit and add the files in their initial state. +This may be a good point to commit the files in their initial state. -``` +``` bash +cd my-project git init -git commit -m initial --allow-empty -git add -A . +git add . git commit -m first ``` ### Install the Cloud SDK CLI tool -https://cloud.google.com/sdk/ +[Cloud SDK: Command Line Interface](https://cloud.google.com/sdk/) ### New App Engine project @@ -1687,15 +1693,15 @@ The Flexible enviroment is also available, but incurs more cost. Create the project. Take note of the instance identifier, which is in the form of `::`. -and see if `gcloud` lists it: +Check if `gcloud` lists the project: -``` +``` bash gcloud projects list ``` Run `init` to authenticate the cli, and select current cloud project. -``` +``` bash gcloud init ``` @@ -1703,11 +1709,11 @@ gcloud init Create the [Cloud SQL database](https://cloud.google.com/sql/docs/postgres/create-manage-databases) which the app is going to use. -Take note of the user name (default is `postgres'`) and password. +Take note of the user name (default is `postgres`) and password. The first database will be created with name `default`. This cannot be deleted. -Create another database, named `strapi`. It may be useful to delete and and re-create this while you are experimenting with the application setup. +Create another database, named `strapi` for example. It may be useful to delete and and re-create this while you are experimenting with the application setup. ### Create app.yaml and .gcloudignore @@ -1734,9 +1740,10 @@ beta_settings: cloud_sql_instances: '' ``` -Create `.gcloudignore` in the project root. +Create `.gcloudignore` in the project root, include `app.yaml` here as well. ``` +app.yaml .gcloudignore .git .gitignore @@ -1752,7 +1759,7 @@ the `.gitignore` entries. The `PostgreSQL` database will need the `pg` package. -``` +``` bash yarn add pg ``` @@ -1822,13 +1829,13 @@ In `package.json`, add the `gcp-build` command to `scripts`: ### Deploy -``` +``` bash gcloud app deploy app.yaml --project myapi-123456 ``` Watch the logs: -``` +``` bash gcloud app logs tail --project=myapi-123456 -s default ``` @@ -1842,12 +1849,14 @@ https://myapp-123456.appspot.com/admin/ Open in develoment mode locally. -``` +``` bash yarn develop ``` Content Type Builder > Create new content type +Create a `Book` type: + ``` model name: book title: text @@ -1856,6 +1865,8 @@ description: rich text Save. +Create an `Author` type: + ``` model name: author name: text @@ -1877,11 +1888,11 @@ The `api/` folder now includes `book` and `author`. Deploy. -``` +``` bash gcloud app deploy app.yaml --project myapi-123456 ``` -It might say `Uploading 0 files`, but if you look the service sources, you should see the new version. +It might say `Uploading 0 files`, but if you look at the service sources, you should see the new version. App Engine > Services > myapi (2 versions) > Source @@ -1889,17 +1900,23 @@ The contents of the `api` folder were deployed, you can inspect the `book` and ` Visit and reload the app URL so that the new version is started up. +``` https://myapi-123456.appspot.com +``` Login to the admin UI. +``` https://myapi-123456.appspot.com/admin +``` Open Books and Authors, add records and create relations. If you haven't enabled the permission yet, the API will respond with `403 Forbidden`. +``` https://myapi-123456.appspot.com/books +``` Update Permissions: @@ -1907,29 +1924,31 @@ Roles and Permissions > Public Enable `count`, `find`, `findone` for `author` and `book`. +``` https://myapi-123456.appspot.com/books +``` -Should returns the JSON data. +Should return the JSON data. ### File uploading to Google Cloud Storage -https://github.com/Lith/strapi-provider-upload-google-cloud-storage +[Lith/strapi-provider-upload-google-cloud-storage](https://github.com/Lith/strapi-provider-upload-google-cloud-storage) -``` +``` bash yarn add strapi-provider-upload-google-cloud-storage ``` -Deploy so that the server app includes the dependency from =package.json=. +Deploy so that the server app includes the dependency from `package.json`. Create a Google service account key. -https://console.cloud.google.com/apis/credentials/serviceaccountkey + Save the JSON credentials file. Plugins > File Upload > Settings > Production tab -By default localhost is selected. Select the Google Cloud Storage plugin. +By default `localhost` is selected. Select the `Google Cloud Storage` plugin. Copy the JSON key and set the regions. @@ -1945,19 +1964,21 @@ Roles & Permissions > Public > Upload Enable `count` and `findone`. +``` https://myapi-123456.appspot.com/upload/files/count +``` Should return `{"count":"0"}`. Files Upload > upload a file. -`/files/count` should new return `1`. +`/files/count` should now return `1`. Logout. Start the local dev server and login to the Admin UI. -``` +``` bash yarn develop ``` @@ -1978,11 +1999,13 @@ Open one of the books and add downloads. Save. The `/books` api should display the associated files. +``` https://myapi-123456.appspot.com/books +``` ### Success! -Read to go! +Ready to go! ### Post-setup configuration @@ -1994,7 +2017,7 @@ CORS is enabled by default, allowing `*` origin. You may want to limit the allow config/environments/production/security.json ``` -**Changing the admin url.** +**Changing the admin url** ``` config/environments/production/server.json From 0dc06354c9e16145dbba91e7a44350bd63bec6b7 Mon Sep 17 00:00:00 2001 From: Gambhiro Date: Wed, 26 Feb 2020 06:52:39 +0000 Subject: [PATCH 5/8] Update docs/3.0.0-beta.x/guides/deployment.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: João Belo --- docs/3.0.0-beta.x/guides/deployment.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/3.0.0-beta.x/guides/deployment.md b/docs/3.0.0-beta.x/guides/deployment.md index 6ea3181e1a..da78fed9d6 100644 --- a/docs/3.0.0-beta.x/guides/deployment.md +++ b/docs/3.0.0-beta.x/guides/deployment.md @@ -1711,7 +1711,7 @@ Create the [Cloud SQL database](https://cloud.google.com/sql/docs/postgres/creat Take note of the user name (default is `postgres`) and password. -The first database will be created with name `default`. This cannot be deleted. +The first database will be created with the name `postgres`. This cannot be deleted. Create another database, named `strapi` for example. It may be useful to delete and and re-create this while you are experimenting with the application setup. @@ -2030,4 +2030,3 @@ config/environments/production/server.json } } ``` - From ba6520a00ef7f49c931238bd5b585a79c976b863 Mon Sep 17 00:00:00 2001 From: Gambhiro Date: Wed, 26 Feb 2020 07:00:21 +0000 Subject: [PATCH 6/8] upd --- docs/3.0.0-beta.x/guides/deployment.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/3.0.0-beta.x/guides/deployment.md b/docs/3.0.0-beta.x/guides/deployment.md index da78fed9d6..9f206e3b4c 100644 --- a/docs/3.0.0-beta.x/guides/deployment.md +++ b/docs/3.0.0-beta.x/guides/deployment.md @@ -1952,10 +1952,12 @@ By default `localhost` is selected. Select the `Google Cloud Storage` plugin. Copy the JSON key and set the regions. -Cloud Console > Storage > Browser +Open the `Cloud Console > Storage > Browser` menu. Copy the bucket name to the plugin settings, the default is the app ID, such as `myapi-123456.appspot.com`. +(Note that the `Access control` setting of the bucket has to be `Fine-grained`, which is the default.) + Save. In the Strapi Admin UI: From 47bc549f82287f83c010c52ace6171d798c277d3 Mon Sep 17 00:00:00 2001 From: Gambhiro Date: Sat, 29 Feb 2020 13:12:49 +0000 Subject: [PATCH 7/8] standard or flexible environment --- docs/3.0.0-beta.x/guides/deployment.md | 38 +++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/3.0.0-beta.x/guides/deployment.md b/docs/3.0.0-beta.x/guides/deployment.md index 9f206e3b4c..33d3e4e7ef 100644 --- a/docs/3.0.0-beta.x/guides/deployment.md +++ b/docs/3.0.0-beta.x/guides/deployment.md @@ -1685,11 +1685,10 @@ Create a new [App Engine](https://console.cloud.google.com/appengine/) project. Select the region, such as `europe-west`. -Language: Node JS +- Language: Node JS +- Environment: Standard (or Flexible) -Environment: Standard - -The Flexible enviroment is also available, but incurs more cost. +(*A note on performance and cost*: the `Standard Environment` is sufficient for development, but it may not be for production. Review the resources your application will need to determine the cost. When you sign up for Google App Engine, it offers a certain amount of free credits which will not be billed.) Create the project. Take note of the instance identifier, which is in the form of `::`. @@ -1723,6 +1722,12 @@ Add `app.yaml` to `.gitignore`. The instance identifier looks like `myapi-123456:europe-west1:myapi`. +The following is an example config for `Standard Environment` or `Flexible Environment`. + +:::: tabs + +::: tab Standard Environment + ``` yaml runtime: nodejs10 @@ -1740,6 +1745,31 @@ beta_settings: cloud_sql_instances: '' ``` +::: + +::: tab Flexible Environment + +``` yaml +runtime: nodejs10 + +env: flex + +env_variables: + HOST: '.appspot.com' + NODE_ENV: 'production' + DATABASE_NAME: 'strapi' + DATABASE_USERNAME: 'postgres' + DATABASE_PASSWORD: '' + INSTANCE_CONNECTION_NAME: '' + +beta_settings: + cloud_sql_instances: '' +``` + +::: + +:::: + Create `.gcloudignore` in the project root, include `app.yaml` here as well. ``` From eace943edc2c8f614d3fccb0a6c72d98c6feb2c0 Mon Sep 17 00:00:00 2001 From: Gambhiro Date: Fri, 6 Mar 2020 15:57:13 +0000 Subject: [PATCH 8/8] remove parts not specific to deployment --- docs/3.0.0-beta.x/guides/deployment.md | 142 +------------------------ 1 file changed, 5 insertions(+), 137 deletions(-) diff --git a/docs/3.0.0-beta.x/guides/deployment.md b/docs/3.0.0-beta.x/guides/deployment.md index 33d3e4e7ef..0ce58817e3 100644 --- a/docs/3.0.0-beta.x/guides/deployment.md +++ b/docs/3.0.0-beta.x/guides/deployment.md @@ -1722,6 +1722,8 @@ 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). + The following is an example config for `Standard Environment` or `Flexible Environment`. :::: tabs @@ -1734,7 +1736,7 @@ runtime: nodejs10 instance_class: F2 env_variables: - HOST: '.appspot.com' + HOST: '.appspot.com' NODE_ENV: 'production' DATABASE_NAME: 'strapi' DATABASE_USERNAME: 'postgres' @@ -1755,7 +1757,7 @@ runtime: nodejs10 env: flex env_variables: - HOST: '.appspot.com' + HOST: '.appspot.com' NODE_ENV: 'production' DATABASE_NAME: 'strapi' DATABASE_USERNAME: 'postgres' @@ -1875,91 +1877,6 @@ Open the admin page and register and admin user. https://myapp-123456.appspot.com/admin/ ``` -### Creating new content types - -Open in develoment mode locally. - -``` bash -yarn develop -``` - -Content Type Builder > Create new content type - -Create a `Book` type: - -``` -model name: book -title: text -description: rich text -``` - -Save. - -Create an `Author` type: - -``` -model name: author -name: text -``` - -Save. - -Open the `Book` type, add a relation: - -``` -book has and belongs to many authors -``` - -Save. - -Logout, quit the quit running app. - -The `api/` folder now includes `book` and `author`. - -Deploy. - -``` bash -gcloud app deploy app.yaml --project myapi-123456 -``` - -It might say `Uploading 0 files`, but if you look at the service sources, you should see the new version. - -App Engine > Services > myapi (2 versions) > Source - -The contents of the `api` folder were deployed, you can inspect the `book` and `author` folders. - -Visit and reload the app URL so that the new version is started up. - -``` -https://myapi-123456.appspot.com -``` - -Login to the admin UI. - -``` -https://myapi-123456.appspot.com/admin -``` - -Open Books and Authors, add records and create relations. - -If you haven't enabled the permission yet, the API will respond with `403 Forbidden`. - -``` -https://myapi-123456.appspot.com/books -``` - -Update Permissions: - -Roles and Permissions > Public - -Enable `count`, `find`, `findone` for `author` and `book`. - -``` -https://myapi-123456.appspot.com/books -``` - -Should return the JSON data. - ### File uploading to Google Cloud Storage [Lith/strapi-provider-upload-google-cloud-storage](https://github.com/Lith/strapi-provider-upload-google-cloud-storage) @@ -1988,56 +1905,7 @@ Copy the bucket name to the plugin settings, the default is the app ID, such as (Note that the `Access control` setting of the bucket has to be `Fine-grained`, which is the default.) -Save. - -In the Strapi Admin UI: - -Roles & Permissions > Public > Upload - -Enable `count` and `findone`. - -``` -https://myapi-123456.appspot.com/upload/files/count -``` - -Should return `{"count":"0"}`. - -Files Upload > upload a file. - -`/files/count` should now return `1`. - -Logout. - -Start the local dev server and login to the Admin UI. - -``` bash -yarn develop -``` - -Add a Media field to the Book type. - -Content Types > Book > Add another field > Media field - -``` -name: downloads -Multiple media -``` - -Save. - -Deploy, and login to the server Admin UI. - -Open one of the books and add downloads. Save. - -The `/books` api should display the associated files. - -``` -https://myapi-123456.appspot.com/books -``` - -### Success! - -Ready to go! +Click `Save`, and it's ready to go! ### Post-setup configuration