From cc0b9a5b5f8dd4d0e3c7f64cbe3506a68a0603ef Mon Sep 17 00:00:00 2001 From: Stuart Date: Thu, 25 Apr 2019 11:13:34 -0400 Subject: [PATCH 1/2] Adding configuration for docker. Makes it easy to run the application on Linux / Windows --- Dockerfile | 12 ++++++++++++ entrypoint.sh | 21 +++++++++++++++++++++ newerhoods/setup.R | 11 +++++++---- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dc36605 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM rocker/geospatial:3.5.0 + + + +RUN apt-get update; apt-get install -y inotify-tools + +ADD . /app +WORKDIR /app +RUN Rscript ./newerhoods/setup.R + +RUN chmod u+x entrypoint.sh +ENTRYPOINT /app/entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..c9790e3 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +PORT=${2-3000} + +start () { + R -e "source('newerhoods/settings_local.R'); shiny::runApp('newerhoods',port=$PORT, host='0.0.0.0')" & + PID=$! +} + +start + +inotifywait -mr newerhoods --format '%e %f' \ + -e modify -e delete -e move -e create \ + | while read event file; do + + echo $event $file + + kill $PID + start + +done diff --git a/newerhoods/setup.R b/newerhoods/setup.R index 0f75785..d9c9e63 100644 --- a/newerhoods/setup.R +++ b/newerhoods/setup.R @@ -1,21 +1,24 @@ +require(devtools) +install.packages('lattice') +devtools::install_version("rgeos",version ='0.3-28') ### packages needed for the App packages <- c("dplyr","readxl","shiny","shinyWidgets","shinyjs", "leaflet","htmltools","shinyBS","shinythemes","markdown", - "shinycssloaders","rgeos","rgdal","maptools","sp","spdep", + "shinycssloaders","rgdal","maptools","sp","spdep", "cluster","fpc","ClustGeo") ## installing required packages -install.packages(packages,quiet = TRUE) +install.packages(packages,quiet = FALSE) ## installing required packages if (!require(gpclib)) { install.packages("gpclib", type="source") - gpclibPermit() + require(gpclib) + #gcplib::gpclibPermit() } ## installing the dev version of bsplus from GitHub -require(devtools) devtools::install_github("ijlyttle/bsplus") From 4c86b2e5d1d46d9ef2f9a935432017e381f61782 Mon Sep 17 00:00:00 2001 From: Stuart Date: Thu, 25 Apr 2019 11:16:04 -0400 Subject: [PATCH 2/2] documenting changes in the README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index e98a094..14689a8 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,20 @@ Run the App library(shiny) runApp("newerhoods") ``` +Alternatively, you can run the application in docker. To build the docker container run + +```bash +docker build -t newerhoods . +``` + +Then to run the docker container simply run + +```bash +docker run -it --rm -p 3000:3000 -v $(pwd):/app newerhoods +``` + +any changes you make in the code should trigger an application reload so all you should need to do is refresh your browser to see them. + ### Contributing to NewerHoods