Deploy
Introduction
There are two main places to deploy Chirp:
- On shinyapps.io
- On your own server
Whichever deployment method you want to choose, you will need a file named app.R
that contains the functions which launches the Chirp: chirp::chirp()
. There is a convenience function to obtain the latter.
chirp::fly()
This will create a file named app.R
in the working directory.
⚠️Important
If you had not specified your credentials
in _chirp.yml
you should either do so or get a token with rtweet from your server. This won't work on shinyapps.io, if you deploy on the latter you have to add your credentials
to the config file.
Docker
The easier way to deploy is probably via docker, pull the container.
docker pull jcoenep/chirp
Then run it by mounting the config file.
docker run -v "$(pwd)"/_chirp.yml:/_chirp.yml -p 3000:80 jcoenep/chirp
Then visit localhost:3000
Shinyapps.io
Deploying on shinyapps.io is probably the easiest solution. This requires the RStudio IDE, which is available for free and runs on any platform (Linux, Mac, and Windows).
Note that there is a thorough guide if the explanation below does not suffice.
- Open your Chirp project in RStudio.
- Create an account on shinyapps.io.
- Install
rsconnect
withinstall.packages('rsconnect')
. - Load
rsconnect
withlibrary(rsconnect)
. - Go to your shinyapps dashboard, click your username and then click "Tokens".
- Click the "Show" button and copy the command.
- Paste and run the command from your project.
- You can then deploy your application with
deployApp()
You should then be able to see your application live at https://myname.shinyapps.io/my-app/
Server
You can setup a Shiny server on pretty much any machine, you can download the Community Edition for free.
The best place to set this up is probably Digital Ocean which offers a great guide in case the instructions below do not suffice.
On a Digital Ocean Ubuntu 16.04 machine, first install R.
sudo apt-get install r-base
Then install the shiny
and remotes
package:
sudo su - -c "R -e \"install.packages(c('shiny', 'remotes'), repos='https://cran.rstudio.com/')\""
Note that all packages should be installed as above so that all users (including shiny) have access to the packages.
Now install Chirp.
sudo su - -c "R -e \"remotes::install_github('JohnCoene/chirp')\""
Now you can install the Shiny server.
sudo apt-get install gdebi-core
wget https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.9.923-amd64.deb
sudo gdebi shiny-server-1.5.9.923-amd64.deb
By default the shiny server runs on port 3838
, make sure it is accessible with:
sudo ufw allow 3838
You can change the port to 80
in the Shiny configuration file.
Your project folder which contains, at least, app.R
and _chirp.yml
, must be copied under srv/shiny-server/
, you can do so however you prefer, i.e.: using Git. You can then visit your application at domain.com/my-directory
.
Note that some options such as the theme
require the server to be restarted in order to take effect; you can do so with.
sudo systemctl restart shiny-server
Need help?
If you have a question or issue feel free to raise it on Github. In case you're unsure how to deploy, I'll happily deploy it for you or your orgnisation in exchange for a ☕: hit the button below and contact me at jcoenep@gmail.com.
Buy me a coffee