无法在 Google Cloud Runner 上 运行 flutter web 应用程序
Can not run flutter web app on Google Cloud Runner
我创建了一个 flutter 应用程序,我想将它部署到云端 运行,
我收到错误消息:
Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information. Logs URL:
然后我按照[疑难解答] https://cloud.google.com/run/docs/troubleshooting
检查了每5个点,找不到任何解决方案
我注意到了信息
No active package dhttpd
我的 Dockerfile 是
# pull official base image
FROM dart
# set working directory
WORKDIR /flutter
# install app dependencies
RUN dart pub global activate dhttpd
# add `/app/node_modules/.bin` to $PATH
ENV PATH $PATH:$HOME/.pub-cache/bin
# add app
COPY build/web ./
EXPOSE 8080
# start app and run at 0.0.0.0
CMD dart pub global run dhttpd --host 0.0.0.0
这就是我的所有信息,
如何使用 Cloud 运行 启动图像?
编辑:
因为我不知道为什么我的图像无法获取 dhttpd ,
我使用过其他静态网络服务,它对我有用
我已经像下面这样更改了 Dockerfile
# pull official base image
FROM node
# set working directory
WORKDIR /flutter
# install app dependencies
RUN npm i -g serve
# add `/app/node_modules/.bin` to $PATH
ENV PATH $PATH:$HOME/.pub-cache/bin
# add app
COPY build/web ./
EXPOSE 8080
# start app and run at 0.0.0.0
CMD serve -p 8080
我在 CMD 行中为 dhttpd 添加了“激活”命令,这会在运行前激活 dhttpd 包。 运行 是镜像构建步骤,运行 命令后容器的状态将提交到容器镜像。 CMD 是启动构建镜像时容器默认执行的命令,Docker文件将仅使用定义的最终 CMD。
另外,我将端口更改为 8082,但它也适用于 8080,您可以使用最适合您的端口。请尝试使用此 Docker 文件:
FROM docker.io/dart
WORKDIR /flutter
ENV PATH $PATH:$HOME/.pub-cache/bin
COPY build/web ./
COPY start.sh ./
EXPOSE 8082
CMD dart pub global activate dhttpd && dart pub global run dhttpd --port=8082 --host=0.0.0.0
我创建了一个 flutter 应用程序,我想将它部署到云端 运行,
我收到错误消息:
Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information. Logs URL:
然后我按照[疑难解答] https://cloud.google.com/run/docs/troubleshooting
检查了每5个点,找不到任何解决方案
我注意到了信息
No active package dhttpd
我的 Dockerfile 是
# pull official base image
FROM dart
# set working directory
WORKDIR /flutter
# install app dependencies
RUN dart pub global activate dhttpd
# add `/app/node_modules/.bin` to $PATH
ENV PATH $PATH:$HOME/.pub-cache/bin
# add app
COPY build/web ./
EXPOSE 8080
# start app and run at 0.0.0.0
CMD dart pub global run dhttpd --host 0.0.0.0
这就是我的所有信息,
如何使用 Cloud 运行 启动图像?
编辑:
因为我不知道为什么我的图像无法获取 dhttpd ,
我使用过其他静态网络服务,它对我有用
我已经像下面这样更改了 Dockerfile
# pull official base image
FROM node
# set working directory
WORKDIR /flutter
# install app dependencies
RUN npm i -g serve
# add `/app/node_modules/.bin` to $PATH
ENV PATH $PATH:$HOME/.pub-cache/bin
# add app
COPY build/web ./
EXPOSE 8080
# start app and run at 0.0.0.0
CMD serve -p 8080
我在 CMD 行中为 dhttpd 添加了“激活”命令,这会在运行前激活 dhttpd 包。 运行 是镜像构建步骤,运行 命令后容器的状态将提交到容器镜像。 CMD 是启动构建镜像时容器默认执行的命令,Docker文件将仅使用定义的最终 CMD。
另外,我将端口更改为 8082,但它也适用于 8080,您可以使用最适合您的端口。请尝试使用此 Docker 文件:
FROM docker.io/dart
WORKDIR /flutter
ENV PATH $PATH:$HOME/.pub-cache/bin
COPY build/web ./
COPY start.sh ./
EXPOSE 8082
CMD dart pub global activate dhttpd && dart pub global run dhttpd --port=8082 --host=0.0.0.0