google app engine flexible with docker 'site cannot be reached'

北城以北 提交于 2019-12-11 17:14:52

问题


I want to server R model using App Engine. I am following this example R with app engine, but stuck. I tried several methods but still have issues. Any guidance on this issue?

Please refer to my code app.yaml

runtime: custom
env: flex

Dockerfile

FROM gcr.io/gcer-public/plumber-appengine
LABEL maintainer="mark"

RUN R -e "install.packages(c('plumber'), repos='http://cran.rstudio.com/')"

WORKDIR /payload/
COPY [".", "./"]

EXPOSE 8080
ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8080)"]
CMD ["schedule.R"]

schedule.R

#* @get /demoR
get_predict_length <- function(){

  dataset <- iris

  # create the model
  model <- lm(Petal.Length ~ Petal.Width, data = dataset)
  petal_width = "0.4"

  #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)
}

I deploy using 'gcloud app deploy and its successful. I get a link 'https://iris-custom-dot-my-project-name.appspot.com/'.

Final output in logs

Stackdriver logs show:

  Starting server to listen on port 8080   

when I click on app engine version https://iris-custom-dot-my-project-name.appspot.com/' , I get below message:

This site can’t be reached


回答1:


Office network issue

In my case the real issue was, my office network blocked port 8080, so when I connected from home or in office over mobile hotspot, it worked.

In general follow below steps to resolve the issue.

1) search google 'my public IP address"

2) Add your IP in firewall rules will resolve the issue.

either use gcloud commands

https://cloud.google.com/sdk/gcloud/reference/app/firewall-rules/create or

using GCP UI ( you can use any priority number which has not been used already)



来源:https://stackoverflow.com/questions/57735491/google-app-engine-flexible-with-docker-site-cannot-be-reached

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!