简体   繁体   中英

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

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

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)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM