简体   繁体   English

如何在谷歌云平台上部署strapi?

[英]How to deploy strapi on google cloud platform?

I'm trying to deploy strapi on google cloud app engine (standard env) but I keep getting a 500 server error. 我正在尝试在谷歌云应用引擎(标准环境)上部署strapi,但我不断收到500服务器错误。 I googled all over but no guides have been written on how to successfully deploy strapi on AE. 我用Google搜索了所有内容,但没有关于如何在AE上成功部署strapi的指南。

I tried the suggestions on this thread: https://github.com/strapi/strapi/issues/2146 So I have: 我试过这个帖子的建议: https//github.com/strapi/strapi/issues/2146所以我有:

  • the gcp-build script to install dependencies 用于安装依赖项的gcp-build脚本
  • an entrypoint in app.yaml to start strapi app.yaml中的一个入口点,以启动strapi
  • my database.json and server.json in strapi are updated 我的database.json和strapi中的server.json已更新

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. 我试着用谷歌搜索错误“app / invalid”,但我似乎无法找到任何相关信息。

I also gave the flex env a spin but that failed as well (without a proper error). 我也给了flex env一个旋转,但也失败了(没有正确的错误)。

This is my app.yaml file: 这是我的app.yaml文件:

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): 这是我的package.json(重要部分):

...
  "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: 生产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: 最后这是我的server.json文件:

{
  "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. 我希望这可以从AE的入门指南中找到,但似乎我错过了一些东西。 Does someone know what that error means? 有人知道那个错误意味着什么吗? Did someone manage to already deploy strapi on AE? 有人设法在AE上部署strapi吗?

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 :) 如果我开始工作,我想将它添加到strapi docs或中等帖子,以便其他人找到它比我更容易:)

Thanks in advance! 提前致谢!

I think your problem provide from server.json file. 我认为你的问题来自server.json文件。

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. 我正在开发一个新的配置文件,以使auth提供程序正常工作......以及其他一些功能。 But this first version is working for me. 但是第一个版本对我有用。

I keep you update of my search if you need. 如果您需要,我会随时更新我的​​搜索。

## Update 1 ## ## Update 1 ##

I found the good configuration for GCP in production mode. 我在生产模式中找到了GCP的良好配置。 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. 我在GCP上使用灵活的环境,但我认为这将在标准模式下工作。

Thanks, 谢谢,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM