This article belongs to the series How to deploy a Shiny app on AWS, divided into 7 parts. To access the other articles, use the following table of contents:
- Part 1: Create a Shiny app.
- Part 2: Create an AWS server.
- Part 3: Install R and R Shiny on your new server.
- Part 4: Deploy the app on the server.
- Part 5: Extra: Create a nice domaine name.
- Part 6: Extra: Secure your app with HTTPS.
- Part 7: Extra: Protect your app with a password.
Recently, a client asked me to build an app with R Shiny. This app was supposed to be used to visualize plenty of indicators and also to interact with the data.
Rather basic for a Shiny app.
So I did my magic, created the dashboard, and the client was super happy!
Except… when he asked me to deploy it on his servers.
That’s when things got complicated.
As a data scientist, any R script has become a piece of cake. And since Shiny is getting more and more traction, I get more and more clients who ask me for automatic Shiny dashboards.
But the problem is when we need to host the app.
I need a server, I need to configure it, update it, administrate it, and… well, it’s not my job.
The “stupid” method
The first time I faced the issue, our team and I decided on a completely different solution.
We had no idea how to set up a server, nor the skills to do it anyway, so… we had to find another way.
It’s not pretty.
We installed R and the Shiny app on each individual computer for each user.
That’s what we did.
Every time we wanted to give access to a new user, we had to go to him, install R on his machine, the libraries, the data, create a shortcut on his desktop…
When you think about it, we were quite creative!
But also incredibly stupid…
- First, we still needed a way to share the data
- Then, it took forever to install the app for each user. Such a waste of time!
- Finally, to maintain the app and deploy updates, it was hell!
But we had no choice.
No skills, and no help from the IT department.
Today, I know there exists a wayyy better solution.
The “smart” method
- Create a server in the cloud
- Send the app there
Ok, ok… I may be oversimplifying it.
It’s not that easy the first time.
But once you know how to do it, you can make it work in half an hour.
And today, with this series of articles, my goal is to teach you exactly how to host a Shiny app on a server.
So, where to start?
First, we’ll use AWS.
AWS is for Amazon Web Services, i.e. all the services from Amazon in the cloud.
Of course, you could use other services, such as Azure from Microsoft, Digital Ocean, Rackspace, etc.
But I only know AWS, so that’s what we’ll use.
An important point to note: When you create a new account on AWS, you have free access to some services for a whole year.
Hence, everything we’ll do in these articles is can be done for free.
The benefits of this smart method are:
- You can deploy the app without moving from your chair and give your client access.
- It’s easy to maintain and update, once everything is set up.
- You can change the server capabilities later on if you need a more powerful machine.
- You can add layers of security and restrict access to the app.
What should you expect from this series?
My goal is to give write an exhaustive guide so that every time you want to deploy a Shiny app, you can refer to these articles.
Until you remember exactly how to do it.
But I know from experience it’s easy to forget. So don’t hesitate to come back when you need.
I will explain each step with plenty of details, screenshots, drawings, maybe even videos!
- Create a Shiny app
- Create an AWS server
- Install R and R Shiny on your new server
- Deploy the app on the server
These steps are enough to get started!
But if you want to go further, I have created these new extra steps:
- Extra: Create a domain name to have a nice URL
- Extra: Secure your app with HTTPS
- Extra: Protect your app with a password
And then we’ll be good!
Let’s start right away with step 1: Create a shiny app
Actually, it’s not exactly the goal of this article to teach you the Shiny framework. So instead of spending time on that, let’s use an an app that already exists.
I chose the movie explorer from the Shiny gallery:
And I created a Gitlab repo so that you can clone it easily: https://gitlab.charlesbordet.com/charles/051-movie-explorer
Note that you’ll need git and a console for this tutorial. You can download git here: https://git-scm.com
Ok, now we’re ready!
To continue to the next step, click here:
Leave a Comment
Required fields are marked *