在使用Docker的Google App Engine Flex中使用水管工部署水管工时出错
我在做什么? 我正在尝试使用docker容器在Google App Engine Flex上部署一个R模型。我的最终目标是将模型用作API。我在使用plumber和docker容器部署应用程序时出错 使用RStudio在我的本地计算机上运行R代码和管道工。但现在我使用的是带有R的AI平台jupyter笔记本。我使用docker Run image name命令在本地测试了docker,一旦docker运行,我就会得到下面的消息在使用Docker的Google App Engine Flex中使用水管工部署水管工时出错,r,docker,google-app-engine,plumber,R,Docker,Google App Engine,Plumber,我在做什么? 我正在尝试使用docker容器在Google App Engine Flex上部署一个R模型。我的最终目标是将模型用作API。我在使用plumber和docker容器部署应用程序时出错 使用RStudio在我的本地计算机上运行R代码和管道工。但现在我使用的是带有R的AI平台jupyter笔记本。我使用docker Run image name命令在本地测试了docker,一旦docker运行,我就会得到下面的消息 Starting server to listen on port
Starting server to listen on port 8080
当我在本地Rstudio中运行R+管道工代码时,会收到以下消息
Starting server to listen on port 8080
Running the swagger UI at http://127.0.0.1:8080/__swagger__/
在此之后,我运行了gcloud app deploy(这会影响构建docker映像等),构建运行了15分钟以上,失败并显示错误消息,如最后所示
代码等详细信息:
应用程序yaml
service: iris-custom
runtime: custom
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 20
# added below to increase app_start_timeout_sec
readiness_check:
path: "/readiness_check"
check_interval_sec: 5
timeout_sec: 4
failure_threshold: 2
success_threshold: 2
app_start_timeout_sec: 900
Dockerfile
FROM gcr.io/gcer-public/plumber-appengine
# install the linux libraries needed for plumber
RUN export DEBIAN_FRONTEND=noninteractive; apt-get -y update \
&& apt-get install -y
# install plumber commented as plumber is preinstalled
#RUN R -e "install.packages(c('plumber'), repos='http://cran.rstudio.com/')"
# copy everything from the current directory into the container
WORKDIR /payload/
COPY [".", "./"]
# open port 8080 to traffic
EXPOSE 8080
# when the container starts, start the main.R script
ENTRYPOINT ["Rscript", "main.R"]
main.R
library(plumber)
r <- plumb("rest_controller.R")
r$run(port=8080, host="0.0.0.0")
#* @get /predict_petal_length
get_predict_length <- function(){
dataset <- iris
# create the model
model <- lm(Petal.Length ~ Petal.Width, data = dataset)
petal_width = "0.4"
# convert the input to a number
petal_width <- as.numeric(petal_width)
#create the prediction data frame
prediction_data <- data.frame(Petal.Width=petal_width)
# create the prediction
predict(model,prediction_data)
}
图书馆(水管工)
r从Google Cloud Doku看来,为了让应用程序通过,它需要返回http状态码200(请参阅)
但是您的应用程序在您为redincess检查定义的路径上返回http状态代码404,因为它不存在
readiness_check:
path: "/readiness_check"
因此,我建议将此路径作为选项添加到rest\u controller.R文件中,如
#* @get /readiness_check
readiness_check<- function(){
return ("app ready")
}
从Google Cloud Doku来看,为了让应用程序通过,似乎需要返回http状态码200(请参阅)
但是您的应用程序在您为redincess检查定义的路径上返回http状态代码404,因为它不存在
readiness_check:
path: "/readiness_check"
因此,我建议将此路径作为选项添加到rest\u controller.R文件中,如
#* @get /readiness_check
readiness_check<- function(){
return ("app ready")
}
@谢谢frank这很有帮助,但部署后仍面临问题参考我的问题@谢谢frank这很有帮助,但部署后仍面临问题参考我的问题