Reputation: 365
I am trying to create a demo which is based on 2 docker containers. Each container runs R-Studio (rocker/verse).
One container is publishing API and another container reading the result using GET (inside ShinyApp). When I test API in Swagger generated by plumber it works, however when I test the Request using Postman then what I get is a R-Studio login page
I could also create a network in and both containers could communicate. What I can read from another container is just the same R-Studio login page
docker network create -d bridge my-net
docker run -d --rm --network=my-net --net-alias=Prod -p 8797:8787 --name Prod rocker/verse
library(plumber)
#* Provide correct configuration automatically
#* @param part_num Part Location in the Group
#* @param grp_num Group Number
#* @get /config
function(part_num, grp_num) {
# read the specification
df1 <- read_csv("/home/myself/r-studio/verify-parts/master_spec.csv")
# extract the needed element
part_num <- as.numeric(part_num)
grp_num <- as.numeric(grp_num)
df1[[part_num]][[grp_num]]
}
plumb(file='api/plumber.R')$run()
docker run -d --rm --network=my-net --net-alias=Dev -p 8787:8787 --name Dev rocker/verse
library(httr)
url <- "172.19.0.2:8787/p/1c2808f8/config?grp_num=a&part_num=b"`
res <- GET(url)
# interpret the results
element <- rawToChar(res$content)
> output is html page with R studio
I expect the output is the character as it was tested in Swagger, but why the actual output is html web object.
Perhaps there is more simple way to test such setup, appreciate relevant help, thanks!
Upvotes: 0
Views: 707
Reputation: 776
Probably because your container entry point is RStudio instead of your plumb file, you cloud use this docker image instead trestletech/plumber
If you dig into the docker images you can see that the entry point of the rocker/verse is port 8787 which is RStudio
You could build your own docker image from rocker/verse and change the entry point while injecting your plumber file.
Something like that with the port used by your plumber api:
COPY ./api/plumber.R /etc/plumber.R
EXPOSE 8000
ENTRYPOINT ["R", "-f", "/etc/plumber.R", "--slave"]
Upvotes: 2