This project repository will help you to set up your R Shiny apps and:
- Containerize using Docker 🐳
- Deploy to Kubernetes ☸️ cluster using manifests
- Deploy to Kubernetes ☸️ cluster using Helm charts
- To-do: Use ShinyProxy for authentication and deploy ShinyProxy to Kubernetes ☸️ cluster
- To-do: Use Nginx HTTP authentication and deploy to Kubernetes ☸️ cluster
I used Windows 10 as my local machine with minikube
setup (Kubernetes) for this project. However, all the tools that I've listed are available on macOS and Linux distros.
Repository branches:
master
branch ➡️ Docker files
kubernetes
➡️ Docker files ➕ Kubernetes deployment with manifests
helm
➡️ Docker files ➕ Kubernetes deployment with Helm chart
Notes:
"master"
branch has files for dockerizing shiny app with shiny server
"kubernetes"
branch has files for dockerizing shiny app and deploying to Kubernetes cluster using manifests
"helm"
branch has files for dockerizing shiny app and deploying to Kubernetes cluster with Helm charts
Please make sure that you have the following software setup on your computer.
-
✨ Git - https://git-scm.com/downloads
-
🚀 WSL 2 (mandatory for Windows) installation steps / or feel free to use other virtualization technologies
-
🐳 Docker - https://hub.docker.com/editions/community/docker-ce-desktop-windows/
-
💻 Other docker UI tools (not mandatory) - docker desktop UI is good enough to view all your containers and images, I personally like Portainer and Dockstation because of their custom features that are not there in the default docker desktop GUI application.
- Portainer - https://documentation.portainer.io/v2.0/deploy/ceinstalldocker/
- Dockstation - https://dockstation.io/
Clone the repository from - https://github.com/py404/r-shiny-docker-kubernetes locally before going to next sections.
For docker deployment, stay in the master branch and proceed to next steps.
Project files and folders required are:
📦r-shiny-docker-kubernetes
┣ 📂app
┃ ┗ 📜app.R
┣ 📂Docker
┃ ┣ 📂nginx
┃ ┃ ┣ 📜nginx.conf
┃ ┃ ┗ 📜nginx.Dockerfile
┃ ┣ 📂shiny
┃ ┃ ┣ 📜index.html
┃ ┃ ┗ 📜shiny.Dockerfile
┃ ┣ 📜.dockerignore
┃ ┗ 📜docker-compose.yml
┣ 📜.gitignore
┗ 📜README.md
🗂️ app folder - contains app.R
which has a simple shiny dashboard
bins app.
To containerize your own shiny apps, copy your project files to app
folder and proceed to next steps for docker deployment.
🗂️ Docker folder - contains docker files for shiny server and nginx.
-
cd
(change directory) toDocker
folder -
Run
docker compose
commanddocker-compose up -d --build
This command will create 2 containers:
(a) a Shiny server container (b) an nginx container
Nginx container acts as a proxy server for connecting to the shiny server.
Docker compose commands breakdown:
-
The following only builds the images, does not start the containers:
docker-compose build
-
The following builds the images if the images do not exist and starts the containers:
docker-compose up
-
If you add the --build option, it is forced to build the images even when not needed:
docker-compose up --build
Navigate to http://localhost:3838 in your browser