如何在Google Cloud Run上运行WordPress? [英] How to run WordPress on Google Cloud Run?

查看:57
本文介绍了如何在Google Cloud Run上运行WordPress?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Cloud Run是新的.是否可以在其上运行WordPress Docker?也许使用gce作为mysql/mariadb的数据库.找不到与此相关的任何讨论

Google Cloud Run is new. Is it possible to run WordPress docker on it? Perhaps using gce as database for the mysql/mariadb. Can't find any discussion on this

推荐答案

尽管我认为这是可能的,但是这并不能很好地利用您的时间来完成本练习.Cloud Run可能不是适合该工作的工具.

Although I think this is possible, it's not a good use of your time to go through this exercise. Cloud Run might not be the right tool for the job.

更新某人为此写了一个教程(使用后果自负):

UPDATE someone blogged a tutorial about this (use at your own risk): https://medium.com/acadevmy/how-to-install-a-wordpress-site-on-google-cloud-run-828bdc0d0e96

这里有几点需要考虑;

Here are a few points to consider;

  1. (更新:这不再是事实)当前Cloud Run不支持本地连接到Cloud SQL(mysql).有一些黑客手段,例如在容器内旋转cloudsql_proxy:如何从Cloud Run安全地连接到Cloud SQL?可以正常工作.

您需要预先准备 wp-config.php 并将其烘烤到您的容器映像中.由于您的容器会不时被删除,因此您应该安装博客(创建 wp-config.php ),并将生成的文件烘烤到容器映像中,以便在容器重新启动时,它不会丢失您的wp-config.php.

You need to prepare your wp-config.php beforehand and bake it into your container image. Since your container will be wiped away every now and then, you should install your blog (creates a wp-config.php) and bake the resulting file into the container image, so that when the container restarts, it doesn't lose your wp-config.php.

永久性存储可能是一个问题:与第2点类似,重新启动容器将在启动后删除保存到该容器中的文件.您需要确保诸如已安装的插件,图像上传等之类的东西不应该写入容器的本地文件系统.(我不确定wordpress是否可以让您将此类文件写入GCS/S3存储桶等其他位置.)要实现这一点,您可能最终会使用 https://wordpress.org/plugins/wp-stateless/插件或

Persistent storage might be a problem: Similar to point #2, restarting a container will delete the files saved to the container after it started. You need to make sure stuff like installed plugins, image uploads etc SHOULD NOT write to the local filesystem of the container. (I'm not sure if wordpress lets you write such files to other places like GCS/S3 buckets.) To achieve this, you'd probably end up using something like the https://wordpress.org/plugins/wp-stateless/ plugin or gcs-media-plugin.

任何写入到Cloud Run容器的本地文件系统的文件也计入容器的可用内存,因此如果您继续向其中写入文件,则您的应用程序可能会用光内存.

Any file written to local filesystem of a Cloud Run container also count towards your container's available memory, so your application may run out of memory if you keep writing files to it.

长话短说,如果您可以确保WP安装未在本地磁盘上写入/修改文件,那么它应该可以正常工作.

Long story short, if you can make sure your WP installation doesn't write/modify files on your local disk, it should be working fine.

我认为Cloud Run可能是此处工作的错误工具,因为它可以无状态"运行.容器,要让WordPress成为无状态是非常困难的,特别是如果您正在安装主题/插件,配置事物等.更不用说,您的Cloud SQL服务器不会是无服务器"的,您将为此付费它也没有收到任何请求.

I think Cloud Run might be the wrong tool for the job here since it runs "stateless" containers, and it's pretty damn hard to make WordPress stateless, especially if you're installing themes/plugins, configuring things etc. Not to mention, your Cloud SQL server won't be "serverless", and you'll be paying for it while it's not getting any requests as well.

(PS,这是尝试并撰写有关博客文章的好方法!如果您这样做,请将其添加到 awesome-cloudrun 回购.)

(P.S. This would be a good exercise to try out and write a blog post about! If you do that, add it to the awesome-cloudrun repo.)

这篇关于如何在Google Cloud Run上运行WordPress?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆