Skip to content

Docker configuration and R code for The Tech's Shiny web apps

Notifications You must be signed in to change notification settings

TheMITTech/shiny-apps

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dockerized Shiny App

This is the Dockerized Shiny App that runs on thetech.com.

This Dockerfile is based on Debian "testing" and r-base image.

The image is forked from shiny-wordcloud on Docker Hub.

Building a Shiny App:

After developing your Shiny App, you will need two files for deployment: ui.R and server.R. Then place the files in a new folder appname in this repo, and add a line to Dockerfile like

COPY /appname/ /srv/shiny-server/appname/

You must build and run the docker image (see Deployment). Then, you can access the app at thetech.com:3838/appname.

Deployment on The Tech website:

  • Navigate to the repo on the tech server (I put it in root home), build a docker image on the tech server with :
docker build -t yourname/yourappname .
  • Run the image with
docker run --rm -p 3838:3838 yourname/yourappname

and you're done!

  • You can run the image in detached mode (in the background) with:
docker run -d -p 3838:3838 yourname/yourappname

Entering the container (for debugging):

docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8f67f0af8a8a thetech/shiny-testing "/usr/bin/shiny-serve" 14 minutes ago Up 14 minutes 0.0.0.0:3838->3838/tcp
  • Grab the container ID and run to pop a shell:
docker exec -it [container-id] bash

Local deploy:

To run this Shiny App on your local machine:

docker run --rm -p 80:3838 [name of docker image]

and it will be available at http://127.0.0.1/ or http://localhost

You can run the container at other ports. It can happen that there is some service running at PORT 80, as Apache or Nginx. To run the app at PORT 3838 for example, you can use:

docker run --rm -p 3838:3838 [name of docker image]

Deploy with a docker based PaaS

If you have a PaaS with Dockerfiles support, like Deis or Dokku, you can git push this image. I just wrote a post with further instructions: Git pushing Shiny Apps with docker and dokku

About

Docker configuration and R code for The Tech's Shiny web apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 88.8%
  • Shell 11.2%