RTVS icon indicating copy to clipboard operation
RTVS copied to clipboard

RTVS Tooling for producing Dockerized Shiny Apps

Open whatevergeek opened this issue 7 years ago • 30 comments

Since RTVS is already leveraging docker in the workspaces, perhaps, can add a feature/tooling to produce dockerize shiny apps.

It'll be like what we have in aspnet core on docker. This will help us deploy our shiny apps (running on docker) anywhere. Feel free to comment if further detail is needed.

whatevergeek avatar May 16 '17 05:05 whatevergeek

Wait, what? RTVS uses Docker?

hongooi73 avatar May 16 '17 07:05 hongooi73

yes! i just saw John Lam's new presentation... so so awesome! he connected to a remote rtvs workspace on docker (rtvs-linux) this is my favorite feature to date...

whatevergeek avatar May 16 '17 11:05 whatevergeek

Ah, I see. RTVS itself doesn't use Docker as far as i know, but you can certainly create a container that includes it.

hongooi73 avatar May 16 '17 13:05 hongooi73

We are still working on it. @jflam 's demo was very early result.

MikhailArkhipov avatar May 16 '17 13:05 MikhailArkhipov

However, be aware that Shiny server is a proprietary product and we can't just produce containers with it. However, the container can encapsulate pre-set client environment which can be connected to and then run Shiny locally.

MikhailArkhipov avatar May 16 '17 13:05 MikhailArkhipov

it's ok.. i was able to pull the image from dockerhub and replicate his demo... so so cool... i love it... when you say "still working on it", does it include tooling for making dockerized shiny apps? i'm think towards using rtvs for creating/developing data products :-)

btw, do you have the dockerfile for rtvs-linux? i want to add my own set of R libraries :-)

whatevergeek avatar May 16 '17 13:05 whatevergeek

Well, "it'll be like what we have in aspnet core on docker. This will help us deploy our shiny apps (running on docker) anywhere". - I'd appreciate some insights what exactly is the expectation :-). If something like a Shiny server, such as the container running on Azure and one can connect to from a browser remotely, that is unlikely since it would entail re-implementing Shiny server on ASP.NET or something like that. Packaging existing server is not possible since it is proprietary product. However, presetting environment and then connecting to a container from another instance of RTVS as remote session certainly possible.

MikhailArkhipov avatar May 16 '17 13:05 MikhailArkhipov

if shiny is proprietary, are we planning to have something equivalent? maybe marry a subset of powerbi? so that we can have a self contained data product within a container that we can deploy anywhere...

whatevergeek avatar May 16 '17 13:05 whatevergeek

We don't yet have a Dockerfile for our Linux container. @karthiknadig built it by hand, so all we have is an image. But we absolutely plan to:

  1. Have Dockerfile + build for all of our images
  2. Have full tooling support for container lifecycle management as well. What would you like to see here?

jflam avatar May 16 '17 18:05 jflam

yes to both

regarding tooling, i understand that embedding shiny in a docker image is a problem... i'm just thinking... let me know if there's any issue on this.... at first, maybe we can have a self-contained r visualization product in docker produced by rtvs... maybe that's for long term... as we have issue currently on embedding the proprietary shiny :-( ...

as an alternative route.... still related to data products and container tooling... Azure ML has a really nice way of exposing API from a model... but this can only be done if connected in the cloud... perhaps, we can have RTVS have tooling support to expose the API into docker once it's built... e.g.

  1. build model in R with all the needed libraries (from a base rtvs image)
  2. have the rtvs tooling help produce/build the new docker image with the model and API support
  3. have the new docker image hosted anywhere (e.g. locally or in azure) once this image runs as a container, it will expose API (e.g. REST) built from the model
  4. Then, from my C# or Python (or other languages)... i can call this API (e.g. http://localhost:1111/is_spam/modelparameter/))

would something like this be possible?

thanks John! :-)

whatevergeek avatar May 17 '17 00:05 whatevergeek

@karthiknadig is looking into options here

MikhailArkhipov avatar Oct 03 '17 16:10 MikhailArkhipov

Thanks @MikhailArkhipov and @karthiknadig

Btw, i tried using Karthik's docker image previously as base... in my own custom dockerfile... seems to work... hence, i'm not making noises after that... hehehe... :-)

On the otherhand, i saw Sirosh's talk on AI few days ago. He talked about deploying models as containers. This is similar to what i have in mind when i posted this previously.

Anyway, feel free to let me know if there's anything I can help and thanks again for looking into this. :-)

whatevergeek avatar Oct 04 '17 02:10 whatevergeek

i agree with paul - the holy grail - which joseph talked about, has been on our radar forever. we just havent had the backend machinery to build a UI against yet. with AML v2.0 some of these will come to fruition and rtvs/ptvs can build proper tooling for them.

On Tue, Oct 3, 2017 at 7:46 PM, Paul [email protected] wrote:

Thanks @MikhailArkhipov https://github.com/mikhailarkhipov and @karthiknadig https://github.com/karthiknadig

Btw, i tried using Karthik's docker image previously as base... in my own custom dockerfile... seems to work... hence, i'm not making noises after that... hehehe... :-)

On the otherhand, i saw Sirosh's talk on AI few days ago. He talked about deploying models as containers. This is similar to what i have in mind when i posted this previously.

Anyway, feel free to let me know if there's anything I can help and thanks again for looking into this. :-)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/RTVS/issues/3535#issuecomment-334035774, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtUVI8qlzfRACEwwmTKdhAk6zW3rJhuks5sovGhgaJpZM4NcASV .

smortaz avatar Oct 04 '17 03:10 smortaz

From prototype experimentation, I was able to docker build a image that would run shiny application. So it should be possible to automate this from RTVS client. However, there is more work needed to figure out the end-to-end workflow, for the build and publish scenarios.

Note: Some R packages cannot be installed without the required OS package installed. For example, curl package requires libcurl4-openssl-dev. So we will need to add these to the docker file as well.

karthiknadig avatar Oct 24 '17 18:10 karthiknadig

@karthiknadig end to end workflow would be great! Thanks for the update! :-)

whatevergeek avatar Oct 24 '17 23:10 whatevergeek

You may already be aware of this, but there are prebuilt R Dockers available at https://hub.docker.com/u/rocker/

Maybe you could leverage those?

hongooi73 avatar Oct 25 '17 00:10 hongooi73

@Hong-Revo you mean using them as base images by @karthiknadig , right? 'cause those images alone can't be used directly with Visual Studio Remote workspaces feature. i'm using kvnadig/rtvs-linux for that... btw, @karthiknadig i saw this on dockerhub: microsoft/rtvs

is this the new image?

whatevergeek avatar Oct 25 '17 00:10 whatevergeek

microsoft/rtvs images are the new set of images. These work with Container UI feature that was added in RTVS 1.3 in VS 2017 15.5 preview 2. Here are the docs to use that feature: https://github.com/Microsoft/RTVS/blob/master/doc/rtvsd/rtvs-docker-container.md

Note: I will add instructions on how to create your own image and container and have it show up in RTVS UI.

karthiknadig avatar Oct 25 '17 01:10 karthiknadig

Wow! This is fresh.. VS2017 15.5 prev2 was just released yesterday.. didn't know this feature is there... will check it out... thanks @karthiknadig

whatevergeek avatar Oct 25 '17 01:10 whatevergeek

@karthiknadig was keen to try... and so i downloaded the new preview version... but felt so sad when i saw this: image

it needs "docker for windows". i can only run docker toolbox on my machine. can we make this work also for docker toolbox?

whatevergeek avatar Oct 25 '17 12:10 whatevergeek

@whatevergeek If you can use the command line to manage the container, you can connect to it from RTVS. Although the RTVS Container UI will be disabled for you (that requires Docker for Windows). I recommend using this Dockerfile template. Note: this will only work with RTVS version 1.3

FROM microsoft/rtvs:1.3-ub1604-rlatest
RUN useradd --create-home ruser1
RUN echo "ruser1:foobar" | chpasswd

The above container will have R 3.4.2, rtvs-daemon, and a bunch of R packages pre-installed.

Build and run the container:

docker build -t my-rtvs-image:latest .
docker run -p 6056:5444 my-rtvs-image:latest rtvsd

Enter connection info like this to add remote connection. Note the port number used in the previous step and here. image

Enter username and password like this. Remember to add the <<unix>>\ prefix. image

Sadly, I don't think we can support docker toolbox based on the development cost. Also, since docker recommends moving to docker for windows. These are some other options you could try: https://github.com/Microsoft/RTVS/blob/master/doc/rtvsd/rtvs-daemon-installation.md Since you are working with VS2017 preview 2, change the rtvs-daemon to this version:

wget -O rtvs-daemon.tar.gz https://github.com/Microsoft/RTVS-Docker/blob/master/1.3/ub1604/base/rtvs-daemon_1.3.31011.1002.tar.gz?raw=true

karthiknadig avatar Oct 25 '17 18:10 karthiknadig

Thanks @karthiknadig I'll try as advised

whatevergeek avatar Oct 25 '17 21:10 whatevergeek

hi @karthiknadig i'm unable to access https://github.com/Microsoft/RTVS-Docker is it a private repo?

image

whatevergeek avatar Oct 26 '17 00:10 whatevergeek

@whatevergeek Forgot about the private repo. here is the path from my repo: https://github.com/karthiknadig/docker-stuff/blob/master/rtvs-daemon_1.3.31011.1002.tar.gz?raw=true

karthiknadig avatar Oct 26 '17 01:10 karthiknadig

Thanks @karthiknadig I'll check accordingly

whatevergeek avatar Oct 26 '17 02:10 whatevergeek

Thanks @karthiknadig I'll check accordingly

whatevergeek avatar Oct 26 '17 02:10 whatevergeek

hi @karthiknadig i'm trying your tutorial on using docker container for RTVS: https://github.com/Microsoft/RTVS/blob/master/doc/rtvsd/rtvs-docker-container.md

After clicking "Create"... it's stuck here: build> Successfully built 3509fe93496b build> Successfully tagged 37a499bb-b42d-c43c-cf54-43da64048bf0:latest build> SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

Any other special setup I need to do? I'm expecting the build container in the VS Container window: image

whatevergeek avatar Oct 26 '17 12:10 whatevergeek

Can you do a docker inspect? on that container. In the resulting JSON, look for PortBindings under HostConfig. Can you paste the result? It should have at least one binding for port 5444/tcp.

karthiknadig avatar Oct 26 '17 12:10 karthiknadig

hi @karthiknadig no container was created... an image was created though... so i did a docker inspect on it: it has 5444/tcp in the "ContainerConfig" and "Config" "ExposedPorts": { "5444/tcp": {} },

apart from "Create" do i need to create something via "From Template" in the Containers Window?

whatevergeek avatar Oct 26 '17 15:10 whatevergeek

When you create a container create it like this:

docker create -p 6060:5444 --name myrtvscontainer 37a499bb-b42d-c43c-cf54-43da64048bf0:latest rtvsd
docker start  myrtvscontainer

I need to investigate why container creation does not happen after build. But lets make sure it can pickup a container after it is created.

karthiknadig avatar Oct 26 '17 15:10 karthiknadig