rstudio / plumber

Turn your R code into a web API.
https://www.rplumber.io
Other
1.39k stars 256 forks source link

Swagger no available when running in docker. #298

Closed ssword closed 6 years ago

ssword commented 6 years ago

First, really thanks for developing this package, it is super cool! I am trying to deploy plumber with docker, here is the last part of my dockerfile:

EXPOSE 5000

ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=5000, swagger = TRUE)"]

CMD ["/usr/src/service/api.R"]

All the API functions running perfect, but I can't visit /__swagger/ page, 404 error. Do I need to configure something else? or it is not supported yet? Thanks.

schloerke commented 6 years ago

It is turned on with the flag that you've set. I don't understand why it's not working.

schloerke commented 6 years ago

@ssword Have you figured out a fix? Does the same plumber router work in a local session?

trestletech commented 6 years ago

__swagger__. Two underscores before and after.

schloerke commented 6 years ago

Good catch @trestletech! Thanks!

@ssword Does the route /__swagger__/ work for you?

ssword commented 6 years ago

@trestletech @schloerke , thanks for the reply. Sorry, I should have responded earlier. I was using __swagger__, (it is the markdown syntax that makes the typo). dunder before and after, and it didn't work. I have also tried the default one.

docker pull trestletech/plumber
docker run -rm -p 5000:8000 trestletech/plumber

Again, I can access /mean, and /sum, but /__swagger__/ still gives 404. I am running the docker in Google cloud platform, Centos 7, with port 5000 open. Is there any other information that I need t provide?

trestletech commented 6 years ago

Can you provide the logs of your container on startup? That would emit info about whether or not Swagger is enabled.

Additionally, what Plumber/R version is your instance running?

ssword commented 6 years ago

@trestletech , thanks, here is the log:

[user@host ~]# docker run --rm -p 5000:8000 trestletech/plumber
ARGUMENT '/usr/local/lib/R/site-library/plumber/examples/04-mean-sum/plumber.R' __ignored__

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8000)
Starting server to listen on port 8000
trestletech commented 6 years ago

The run call there is missing swagger=TRUE

trestletech commented 6 years ago

Stale docker image that needs rebuilding on the remote server?

ssword commented 6 years ago

@trestletech you are right, after adding swagger=TRUE to the default docker image, swagger UI is enabled. I will check my own docker file again, than you!

ssword commented 6 years ago

@trestletech , sorry, it's my bad, I was using the file with pr$run as command args instead of the original function file. I will close the issue.