Skip to content

Commit

Permalink
find out working directory of shell, and of app
Browse files Browse the repository at this point in the history
  • Loading branch information
spfeiffe committed May 21, 2024
1 parent 3f152de commit ededebc
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ WORKDIR /app
# This one seemed to break some packages:
# RUN echo "PKG_CPPFLAGS=-Wno-format-security" >> ~/.R/Makevars

RUN pwd
# RUN pwd
# # changed this part to not use renv (I'm experimenting)
# RUN Rscript -e 'install.packages("remotes")'
# RUN Rscript 'install_all_packages_in_lockfile.R'
Expand Down
37 changes: 19 additions & 18 deletions Dockerfile.bak
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ FROM rocker/shiny:4.4.0
# I added this label, though it doesn't do anything
LABEL name=ContDataSumViz

# This part is the part that installs the system packages, usually needed for use in compiling some R package.
# I just added packages to this list as I got errors
RUN apt-get update && apt-get install -y \
libssl-dev \
libxml2-dev \
libgit2-dev \
default-jdk \
r-cran-rjava \
r-base-dev dh-r automake \
libharfbuzz-dev libfribidi-dev \
libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev \
libgdal-dev \
libudunits2-dev \
cmake \
&& apt-get clean
# # This part is the part that installs the system packages, usually needed for use in compiling some R package.
# # I just added packages to this list as I got errors
# RUN apt-get update && apt-get install -y \
# libssl-dev \
# libxml2-dev \
# libgit2-dev \
# default-jdk \
# r-cran-rjava \
# r-base-dev dh-r automake \
# libharfbuzz-dev libfribidi-dev \
# libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev \
# libgdal-dev \
# libudunits2-dev \
# cmake \
# && apt-get clean

# This sets the main path in the docker image to /app, which is a standard practice.
WORKDIR /app
Expand All @@ -35,9 +35,10 @@ WORKDIR /app
# This one seemed to break some packages:
# RUN echo "PKG_CPPFLAGS=-Wno-format-security" >> ~/.R/Makevars

# changed this part to not use renv (I'm experimenting)
RUN Rscript -e 'install.packages("remotes")'
RUN Rscript 'install_all_packages_in_lockfile.R'
RUN pwd
# # changed this part to not use renv (I'm experimenting)
# RUN Rscript -e 'install.packages("remotes")'
# RUN Rscript 'install_all_packages_in_lockfile.R'

# This part copies in the rest of the project
COPY . /app
Expand Down
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@


# Define UI for miles per gallon app ----
ui <- fluidPage (
titlePanel("Miles Per Gallon"),
sidebarLayout (
sidebarPanel(),
mainPanel (
textOutput("myTextOutput"),
br(),
textOutput("myTextOutput2")
)
),
theme = bslib::bs_theme(version = "5")
)

# Define server logic to plot various variables against mpg ----
server <- function(input, output) {
#i <- installed.packages()
#session_ID <- reactive({ as.character(floor(runif(1)*1e20)) })
#output$myTextOutput <- renderPrint({
# paste0("session_ID = ", session_ID())
# })
#output$myTextOutput <- renderPrint({
# list.files()
# })
#output$myTextOutput <- renderPrint({
# cat(unname(sort(unique(i[,1]))), sep=" \n")
# })
output$myTextOutput <- renderPrint ({
system2('echo $(pwd)', stdout=TRUE, stderr=TRUE) # bash equivalent of getwd() # 'echo $(pwd)"/app"'
})
output$myTextOutput2 <- renderPrint ({
getwd()
})
}

shinyApp(ui, server)
37 changes: 37 additions & 0 deletions app.R.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@


# Define UI for miles per gallon app ----
ui <- fluidPage (
titlePanel("Miles Per Gallon"),
sidebarLayout (
sidebarPanel(),
mainPanel (
textOutput("myTextOutput"),
br(),
textOutput("myTextOutput2")
)
),
theme = bslib::bs_theme(version = "5")
)

# Define server logic to plot various variables against mpg ----
server <- function(input, output) {
#i <- installed.packages()
#session_ID <- reactive({ as.character(floor(runif(1)*1e20)) })
#output$myTextOutput <- renderPrint({
# paste0("session_ID = ", session_ID())
# })
#output$myTextOutput <- renderPrint({
# list.files()
# })
#output$myTextOutput <- renderPrint({
# cat(unname(sort(unique(i[,1]))), sep=" \n")
# })
output$myTextOutput <- renderPrint ({
paste0 (
system2('echo $(pwd)"/app"', stdout=TRUE, stderr=TRUE)
getwd()
})
}

shinyApp(ui, server)

0 comments on commit ededebc

Please sign in to comment.