为测试目的构建了一个包含30GB以上的单个文件的巨大映像后,将映像部署到Cloud Run中之后,我无法下载相同的文件。
只需说明一下,该映像确实可以构建并在Cloud Run上运行,但是由于某些原因,特定的大文件不可用。
这是一个示例Dockerfile来重现此错误:
FROM python:3
WORKDIR /app
RUN touch test # downloading this file works fine
RUN dd if=/dev/urandom of=file bs=1M count=32768 # this one takes a while to build and to deploy, and won't be downloadable later on.
EXPOSE 8080
CMD python -m http.server 8080 --bind 0.0.0.0
尝试通过wget下载文件将返回以下内容:
wget https://cloud-run-link-here.app/file
--2020-03-03 17:19:16-- https://cloud-run-link-here.app/file
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving cloud-run-link-here.app (bigdocker-7k3mrt42la-uc.a.run.app)... :::::0, 0.0.0.0
Connecting to cloud-run-link-here.app (cloud-run-link-here.app)|:::::0|:443... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2020-03-03 17:19:17 ERROR 500: Internal Server Error.
在本地进行相同的操作就可以了。
Cloud Run的最大响应大小为32MB,不建议将Python标准库中的HTTP服务器用于生产。它很可能没有试图将非常大的请求分块并失败。
您应该考虑使用生产HTTP服务器(例如gunicorn)来代替。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句