From 0d8f4eb1aac07cfc4f30247d69d4ce38ac65bd4a Mon Sep 17 00:00:00 2001 From: Hannah Date: Mon, 6 Apr 2020 15:10:31 -0700 Subject: [PATCH 1/4] added 5 files for app, and updated init.R (packages) and app.json (metadata) --- Dockerfile | 16 ++++++++++++++++ app.json | 9 +++++++++ apt-packages | 3 +++ heroku.yml | 3 +++ init.R | 24 ++++++++++++++++++++++++ 5 files changed, 55 insertions(+) create mode 100644 Dockerfile create mode 100644 app.json create mode 100644 apt-packages create mode 100644 heroku.yml create mode 100644 init.R diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..896d63c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM plotly/heroku-docker-r:3.6.2_heroku18 + +# on build, copy application files +COPY . /app/ + +# for installing additional dependencies etc. +RUN if [ -f '/app/onbuild' ]; then bash /app/onbuild; fi; + +# look for /app/apt-packages and if it exists, install the packages contained +RUN if [ -f '/app/apt-packages' ]; then apt-get update -q && cat apt-packages | xargs apt-get -qy install && rm -rf /var/lib/apt/lists/*; fi; + +# look for /app/init.R and if it exists, execute it +RUN if [ -f '/app/init.R' ]; then /usr/bin/R --no-init-file --no-save --quiet --slave -f /app/init.R; fi; + +# here app.R needs to match the name of the file which contains your app +CMD cd /app && /usr/bin/R --no-save -f /app/app.R diff --git a/app.json b/app.json new file mode 100644 index 0000000..dae15a4 --- /dev/null +++ b/app.json @@ -0,0 +1,9 @@ +{ + "name": "Testing deployment of DashR app to heroku", + "description": "This app shows 1994 census data, in a 2020 kind of way.", + "keywords": [ + "heroku", + "R deployment", + "Dash R" +], +} diff --git a/apt-packages b/apt-packages new file mode 100644 index 0000000..187885d --- /dev/null +++ b/apt-packages @@ -0,0 +1,3 @@ +libcurl4-openssl-dev +libxml2-dev +libv8-3.14-dev diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..2b8f79b --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + web: Dockerfile \ No newline at end of file diff --git a/init.R b/init.R new file mode 100644 index 0000000..7075994 --- /dev/null +++ b/init.R @@ -0,0 +1,24 @@ +# R script to run author supplied code, typically used to install additional R packages +# contains placeholders which are inserted by the compile script +# NOTE: this script is executed in the chroot context; check paths! + +r <- getOption('repos') +r['CRAN'] <- 'http://cloud.r-project.org' +options(repos=r) + +# ====================================================================== + +# packages go here +install.packages('remotes') + +remotes::install_github('plotly/dashR', upgrade=TRUE) +install.packages('dash') +install.packages('dashCoreComponents') +install.packages('dashHtmlComponents') +install.packages('dashTable') +install.packages('tidyverse') +install.packages('here') +install.packages('glue') +install.packages('ggpubr') +install.packages('scales') +install.packages('plotly') From f9538736834eda7a6b7d81d2e8a07c4d1b794ae8 Mon Sep 17 00:00:00 2001 From: Hannah Date: Mon, 6 Apr 2020 16:01:38 -0700 Subject: [PATCH 2/4] updated init.R --- init.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/init.R b/init.R index 7075994..2f5990d 100644 --- a/init.R +++ b/init.R @@ -12,12 +12,11 @@ options(repos=r) install.packages('remotes') remotes::install_github('plotly/dashR', upgrade=TRUE) -install.packages('dash') install.packages('dashCoreComponents') install.packages('dashHtmlComponents') install.packages('dashTable') -install.packages('tidyverse') install.packages('here') +install.packages('tidyverse') install.packages('glue') install.packages('ggpubr') install.packages('scales') From d4f97f2bdf5f222d1920c608d77839c1b61777d8 Mon Sep 17 00:00:00 2001 From: Hannah Date: Mon, 6 Apr 2020 18:52:18 -0700 Subject: [PATCH 3/4] debug = FALSE --- app.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.R b/app.R index c5fae70..2e6f58e 100644 --- a/app.R +++ b/app.R @@ -236,7 +236,7 @@ app$callback( }) # Run app -app$run_server(debug = TRUE) +app$run_server(debug = FALSE) # command to add dash app in Rstudio viewer: # rstudioapi::viewer("http://127.0.0.1:8050") \ No newline at end of file From 7b8406adc6ef4843c9705ff0c76b66550f852e08 Mon Sep 17 00:00:00 2001 From: Firas Moosvi Date: Mon, 6 Apr 2020 23:23:06 -0700 Subject: [PATCH 4/4] Update app.R --- app.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.R b/app.R index 2e6f58e..6104800 100644 --- a/app.R +++ b/app.R @@ -236,7 +236,7 @@ app$callback( }) # Run app -app$run_server(debug = FALSE) +app$run_server(host = "0.0.0.0", port = Sys.getenv('PORT', 8050)) # command to add dash app in Rstudio viewer: -# rstudioapi::viewer("http://127.0.0.1:8050") \ No newline at end of file +# rstudioapi::viewer("http://127.0.0.1:8050")