我是Web开发的新手。我遵循了Firebase团队已在YouTube上上传的本教程。通过Cloud Run在Firebase托管上部署Python-Firecast
将项目部署到Cloud Run之后,我能够在Firebase Hosting本地服务器https:// localhost:5000上运行它。我想更改index.html中的代码,但是即使在编辑器(VScode)中更改代码并刷新浏览器后,本地服务器也无法反映更改。现在,我必须运行以下命令来更新本地服务器中的更改,但这确实很耗时。
$gcloud builds submit --tag gcr.io/ projectName / serviceId
$gcloud run deploy serviceId --region us-central1 --platform managed --image gcr.io/ projectName / serviceId
$node_modules/.bin/firebase serve
有什么方法可以在不运行上述代码的情况下在Firebase Hosting本地服务器中看到index.html中的更改?
项目目录
project
---server
---Dockerfile
---src
---app.py
---templates
---index.html
---static
---styles.css
---icons8-pause.png
---firebase.json
---.firebaserc
---package.json
---node_modules
index.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flask + Firebase + CLoud Run = FIRE</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body class="full-screen flex-center">
<h1 class="text-xl">FLASK + Firebase = Awesome + Cool + Nice</h1>
<h2>Hello World</h2>
<a href="/my-link/">Click me</a>
<img src="/icons8-pause.png" alt="">
<h3> {{ context.server_time }}</h3>
</body>
</html>
firebase.json
{
"hosting": {
"public": "static",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [{
"source": "**",
"run": {
"serviceId": "serviceId"
}
}]
}
}
不幸的是,当你将Firebase Hosting与Cloud Run一起使用时,有必要使用这些命令,因为你需要将应用程序容器化并将其上载到Container Registry,以便进行部署。例如,即使在这个简单的Hello World
示例中,它也需要运行命令。
总而言之,考虑到应用程序的结构和格式(使用Cloud Run进行部署),执行命令将需要它,因此应用程序已被容器化并正确上载,因此可以正确进行部署。你也可以通过此处的官方文档获取所有详细信息。