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.R b/app.R index e4d8837..8593bb0 100644 --- a/app.R +++ b/app.R @@ -236,7 +236,7 @@ app$callback( }) # Run app -app$run_server(debug = TRUE) +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") 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..2f5990d --- /dev/null +++ b/init.R @@ -0,0 +1,23 @@ +# 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('dashCoreComponents') +install.packages('dashHtmlComponents') +install.packages('dashTable') +install.packages('here') +install.packages('tidyverse') +install.packages('glue') +install.packages('ggpubr') +install.packages('scales') +install.packages('plotly')