Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker and HAproxy example #16

Open
dselivanov opened this issue May 29, 2018 · 7 comments
Open

Docker and HAproxy example #16

dselivanov opened this issue May 29, 2018 · 7 comments
Labels

Comments

@dselivanov
Copy link
Collaborator

http and tcp forwarding

@dselivanov
Copy link
Collaborator Author

docker available at https://hub.docker.com/r/dselivanov/restrserve/

@vikram-rawat
Copy link

Link points to a 404 error page. It doesn't exist i guess

@dselivanov
Copy link
Collaborator Author

@vikram-rawat please refer to the readme - https://restrserve.org/#docker as the source of truth.

@d3an
Copy link

d3an commented Mar 20, 2021

I got a PoC working with this:

Dockerfile

FROM rocker/r-base:latest

RUN mkdir -p /app
COPY . /app

RUN Rscript /app/install_packages.R

CMD Rscript /app/server.R

app/install_packages.R

install.packages("RestRserve", repos = "https://cloud.r-project.org")
install.packages("readr")

app/server.R

library(RestRserve)

app = Application$new()

app$add_get(
  path = "/health", 
  FUN = function(.req, .res) {
    .res$set_body("OK")
  })

app$add_post(
  path = "/addone", 
  FUN = function(.req, .res) {
    result = list(x = .req$body$x + 1L)
    .res$set_content_type("application/json")
    .res$set_body(result)
  })

backend = BackendRserve$new()
backend$start(app, http_port = 8080)

Build Steps

$ docker pull rocker/r-base
$ docker build -t username/image_name .  # build time took like 10mins tho
$ docker run --rm -it -p 8080:8080 username/image_name

Testing

$ curl http://localhost:8080/health
OK
$ curl -X POST -H "Content-Type: application/json" -d '{"x":4}' http://localhost:8080/addone
{"x":5}

@dselivanov
Copy link
Collaborator Author

@d3an that looks like an ordinal example of RestRserve docker image, but not a RestRserve paired with HAproxy. As for standard RestRserve base docker images I suggest "official" one - https://hub.docker.com/repository/docker/rexyai/restrserve (and corresponding Dockerfile)

@ncullen93
Copy link

Hi @dselivanov is there a reason you removed HAproxy from the base docker? Is it no longer recommended or was that to just make things simpler?

@dselivanov
Copy link
Collaborator Author

To make things simpler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants