我刚刚部署了一个 Cloud Run REST API 应用程序,该应用程序使用 Google Cloud Storage API 从存储桶以及该存储桶内的文件夹中获取最后一个文件。这是我正在使用的代码:
import os
import logging
from flask import Flask
from flask import request, jsonify, render_template
from google.oauth2 import service_account
from google.cloud import storage
from bson.json_util import dumps
app = Flask(__name__)
storage_client = storage.Client.from_service_account_json('sa.json')
@app.route('/')
# API Version 1.0
def index():
"""Welcome to Last File API Version 1.0."""
button_text = "Add File"
return render_template('main.html', button_text=button_text)
@app.route("/last_file_m_individual/", methods=["GET"])
def list_m_individual_files():
"""List all files in GCP bucket."""
bucketName = request.args.get('bucketname')
bucketFolder = request.args.get('bucketfolder') …Run Code Online (Sandbox Code Playgroud) 我正在使用 Cloud Run + Cloud Firestore 构建一个简单的基于 Flask 的应用程序。有一种方法带来了很多数据,日志都显示这个错误:
`Memory limit of 244M exceeded with 248M used. Consider increasing the memory limit, see https://cloud.google.com/run/docs/configuring/memory-limits`
Run Code Online (Sandbox Code Playgroud)
如何增加 cloudbuild.yaml 中的内存限制?我们的 YAML 文件包含以下内容:
# cloudbuild.yaml
steps:
# build & push the container image
- name: "gcr.io/kaniko-project/executor:latest"
args: ["--cache=true", "--cache-ttl=48h", "--destination=gcr.io/$PROJECT_ID/todo:latest"]
# Deploy container image to Cloud Run
- name: "gcr.io/cloud-builders/gcloud"
args: ['beta', 'run', 'deploy', 'todo', '--image', 'gcr.io/$PROJECT_ID/todo:latest', '--region', 'us-central1', '--allow-unauthenticated', '--platform', 'managed']
Run Code Online (Sandbox Code Playgroud)
谢谢
python containers flask google-cloud-platform google-cloud-run