title: Shiny App shows "undefined", UI appears on reload
body: <p>I have a rather complicated shiny app which successfully runs locally. 
  Previously it was also successfully dockerized and ran ok in VirtualBox VM (Debian x64) via shinyproxy.</p>
  
  <p>With the last docker images re-build the app does not work properly any longer, the container runs, log files show that the app starts,
  however there is no UI, just 'undefined' in browser. After the reload in browser the app UI appears.</p>
  
  <p>For easier troubleshooting I have replaced my complicated app with small demo-app, leaving the Dockerfile the same,
  with lots of used in my complicated app libraries.</p>
  
  <p>The demo-app consists of server.R, ui.R and global.R</p>
  
  <p>I have the same strange result: 'undefined' instead of UI, the app appears after reload.</p>
  
  <p>If I move all the libraries to server.R and delete global.R, then the problem is solved, the app UI appears immediately.</p>
  
  <p>Here is my Dockerfile:</p>
  
  <pre><code># Ubuntu 16.04 LTS with R
  FROM openanalytics/r-base 
  
  # system libraries of general use
  RUN apt-get update &amp;&amp; apt-get install -y \
      sudo \
      pandoc \
      pandoc-citeproc \
      libcurl4-gnutls-dev \
      libcairo2-dev \
      libxt-dev \
      libssl-dev \
      libssh2-1-dev \
      libssl1.0.0 \
      libxml2-dev \
      libpq-dev \
      libgdal-dev \
      libproj-dev
  
  
  RUN R -e "install.packages(c('remotes', 'RPostgreSQL', 'stringi', 'shiny', 
  'shinydashboard',  'shinyjs', 'leaflet', 'plyr', 'dplyr', 'data.table', 
  'scales', 'rgdal', 'sp', 'shinyBS', 'devtools','DT','rgeos','shinyjqui'), 
  repos='https://cloud.r-project.org/')"
  RUN installGithub.r hadley/ggplot2
  
  RUN R -e "install.packages(c('tidyr', 'hexbin', 'purrr'), 
  repos='https://cloud.r-project.org/')"
  RUN installGithub.r ropensci/plotly 
  RUN rm -rf /tmp/downloaded_packages/
  
  
  RUN apt-get update &amp;&amp; apt-get install -y \
      default-jre \
      default-jdk \
      libv8-3.14-dev
  
  RUN R -e "install.packages(c('rhandsontable', 'V8'), repos='https://cloud.r-
  project.org/')"
  
  RUN apt-get update &amp;&amp; apt-get install -y \
      r-cran-rjava
  
  RUN R -e "install.packages(c('rJava', 'xlsxjars'), repos='https://cloud.r-
  project.org/')"
  RUN R -e "install.packages(c('xlsx'), repos='https://cloud.r-project.org/')"
  
  RUN installGithub.r jrowen/rhandsontable
  RUN installGithub.r dreamRs/shinyWidgets
  RUN rm -rf /tmp/downloaded_packages/
  
  
  RUN mkdir /root/test_app2
  COPY test_app2 /root/test_app2
  
  COPY Rprofile.site /usr/lib/R/etc/
  
  EXPOSE 3838
  
  CMD ["R", "-e shiny::runApp('/root/test_app2')"]
  </code></pre>
  
  <p>server.R</p>
  
  <pre><code>    server &lt;- function(input, output) {
  
        datasetInput &lt;- reactive({
          switch(input$dataset,
                 "rock" = rock,
                 "pressure" = pressure,
                 "cars" = cars)
        })
  
        output$summary &lt;- renderPrint({
          dataset &lt;- datasetInput()
          summary(dataset)
        })
  
    output$view &lt;- renderTable({
      head(datasetInput(), n = input$obs)
    })
  </code></pre>
  
  <p>}</p>
  
  <p>ui.R</p>
  
  <pre><code>ui &lt;- fluidPage(
  
    titlePanel("Shiny Text"),
  
    sidebarLayout(
  
      sidebarPanel(
  
        selectInput(inputId = "dataset",
                    label = "Choose a dataset:",
                    choices = c("rock", "pressure", "cars")),
  
        numericInput(inputId = "obs",
                     label = "Number of observations to view:",
                     value = 10)
      ),
  
      mainPanel(
        verbatimTextOutput("summary"),
        tableOutput("view")
  
      )
    )
  )
  </code></pre>
  
  <p>global.R</p>
  
  <pre><code>library(RPostgreSQL)
  library(stringi)
  library(shiny)
  library(shinydashboard)
  library(shinyjs)
  library(leaflet)
  library(plyr)
  library(dplyr)
  library(data.table)
  library(ggplot2)
  library(plotly)
  library(scales)
  library(rgdal)
  library(sp)
  library(shinyBS)
  library(rhandsontable)
  library(xlsx)
  library(shinyWidgets)
  library(reshape2)
  library(tools)
  library(DT)
  </code></pre>
  
  <p>Can anyone help please?</p>
  
  <p>Update: Minimized Dockerfile with the same problem:</p>
  
  <pre><code>FROM openanalytics/r-base 
  
  RUN apt-get update &amp;&amp; apt-get install -y \
      sudo \
      pandoc \
      pandoc-citeproc \
      libcurl4-gnutls-dev \
      libcairo2-dev \
      libxt-dev \
      libssl-dev \
      libssh2-1-dev \
      libssl1.0.0 \
      libxml2-dev \
      libpq-dev \
      libgdal-dev \
      libproj-dev
  
  RUN R -e "install.packages(c( 'shiny','dplyr'), repos='https://cloud.r-project.org/')"
  
  RUN rm -rf /tmp/downloaded_packages/
  
  RUN apt-get update &amp;&amp; apt-get install -y \
      default-jre \
      default-jdk \
      libv8-3.14-dev
  
  RUN apt-get update &amp;&amp; apt-get install -y \
      r-cran-rjava
  
  RUN R -e "install.packages(c('rJava', 'xlsxjars'), repos='https://cloud.r-project.org/')"
  RUN R -e "install.packages(c('xlsx'), repos='https://cloud.r-project.org/')"
  
  RUN rm -rf /tmp/downloaded_packages/
  
  RUN mkdir /root/test_app2
  COPY test_app2 /root/test_app2
  
  COPY Rprofile.site /usr/lib/R/etc/
  
  EXPOSE 3838
  
  CMD ["R", "-e shiny::runApp('/root/test_app2')"]
  </code></pre>
  
  <p>Having only three libraries - <code>shiny, xlsx, dplyr</code> - produces the same <code>'undefined'</code> result. But only on the first container run after the build, then the app runs ok (with login/logout, restarting docker service and shinyproxy service). Combinations <code>shiny &amp; xlsx</code> or <code>shiny &amp; dplyr</code> do not result in <code>'undefined'</code>  </p>