Commit a5c93fa3 authored by Jean-Karim Heriche's avatar Jean-Karim Heriche

Modifications to improve container use in ShinyProxy.

parent c531b51f
......@@ -7,29 +7,12 @@ RUN apt-get install -y openjdk-8-jdk
# Install required R packages
RUN R CMD javareconf
RUN R -e "install.packages('rJava', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('remotes', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('rversions', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('roxygen2', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('xml2', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('devtools', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages(c('rJava', 'remotes', 'rversions', 'roxygen2', 'xml2', 'devtools'), repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('BiocManager', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "BiocManager::install('aoles/RBioFormats')"
RUN R -e "BiocManager::install('EBImage')"
RUN R -e "install.packages('DT', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('shiny', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('shinyFiles', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('shinycssloaders', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('shinydashboard', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('shinyjs', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('shinyWidgets', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('shinybusy', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('assertthat', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('ggplot2', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('plotly', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('RANN', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('MASS', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages('uwot', repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages(c('DT', 'shiny', 'shinyFiles', 'shinycssloaders', 'shinydashboard', 'shinyjs', 'shinyWidgets', 'shinybusy', 'assertthat'), repos='https://ftp.gwdg.de/pub/misc/cran/')"
RUN R -e "install.packages(c('ggplot2', 'plotly', 'RANN', 'MASS', 'uwot'), repos='https://ftp.gwdg.de/pub/misc/cran/')"
# Copy the app to the image
RUN mkdir -p /usr/local/app/image-data-explorer
......@@ -44,17 +27,15 @@ RUN R -e "library(devtools);setwd('/usr/local/app/image-data-explorer/imageViewe
# IDE is available on port 5476
EXPOSE 5476
# Create a directory to mount eventual data
RUN mkdir -p /data
ENV DATADIR="/data"
# Create user
RUN useradd -m ide -d /home/ide
# Set working directory
WORKDIR /home/ide
# Run as user ide to avoid running as root or require user to run
# with the --user flag
USER ide
# Run the app
WORKDIR "/usr/local/app/image-data-explorer"
CMD ["Rscript","image_data_explorer.R"]
CMD ["R", "-e", "shiny::runApp('/usr/local/app/image-data-explorer/image_data_explorer.R', host = '0.0.0.0', port = 5476)"]
......@@ -104,8 +104,20 @@ SelectVariable <-function( name, output_name ){
input_data_server <- function(input, output, session) {
ns <- session$ns # Allow to use ns() input in the server
## Server-side directories we're allowed to navigate to find the image root dir
roots = c(home = "~", wd = '.')
## Server-side directories we're allowed to navigate to find the image root dir.
## We need different treatments depending on whether or not we're running in a container.
## The environment variable DATADIR is defined in the Dockerfile
data.dir <- Sys.getenv("DATADIR")
user.name <- Sys.getenv("USER")
home.dir <- Sys.getenv("HOME")
roots <- NULL
if(is.null(data.dir) || data.dir=="") {
# We're likely not in a container
roots = c(home = home.dir)
} else {
# We're likely in a container
roots = c(data = data.dir)
}
# Vector of user input names (i.e. inputId) that we may want to restore from file
# Values are stored in rv$inputChoices
......@@ -325,7 +337,7 @@ input_data_server <- function(input, output, session) {
sep = input$sep,
quote = input$quote,
stringsAsFactors = FALSE)
## Try and detect use of wrong separator
## Try to detect use of wrong separator
if(ncol(rv$data)<2) {
showNotification("Possible use of wrong field separator detected. Please select the correct field separator before uploading the file again.",
type = "warning",
......
......@@ -48,7 +48,7 @@ options(shiny.maxRequestSize=500*1024^2)
# options(java.parameters = "-Xmx8g" )
## Making data table filtering persistent
## from https://dev.to/awwsmm/reactive-datatables-in-r-with-persistent-filters-l26 u
## from https://dev.to/awwsmm/reactive-datatables-in-r-with-persistent-filters-l26
## Default global search value
if (!exists("defaultSearch")) defaultSearch <- ""
## Default column search values
......@@ -62,9 +62,9 @@ source("R/explore.R")
source("R/dim_reduction.R")
ui <- function(request) {
dashboardPage(
dashboardHeader(title = "Image Data Explorer"),
dashboardHeader(title = "Image Data Explorer"),
## Sidebar with input and output definitions
dashboardSidebar(sidebarMenuOutput("menu")),
......@@ -102,7 +102,7 @@ ui <- function(request) {
server <- function(input,output,session){
ns <- session$ns # Allow to use ns() in the server
ns <- session$ns # Allow to use ns() in the server
## To update menu areas
react <- reactiveValues(update_key = NULL)
......@@ -155,8 +155,7 @@ server <- function(input,output,session){
# callModule(cluster_server, "cluster_module", global_data, session)
# }
# }, ignoreNULL = TRUE, ignoreInit = TRUE)
}
# Run the application
......@@ -167,4 +166,4 @@ IDE <- shinyApp(ui = ui,
# Supply desired port to runApp() because it ignores options in shinyApp()
## Need to supply host for use in Docker container
runApp(IDE, port = 5476, host = "0.0.0.0")
#runApp(IDE, port = 5476, host = "0.0.0.0")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment