Commit b7e58189 authored by Charles's avatar Charles

fix deployment files

there was an issue with reading global variables
and in the Dockerfile
parent 1a03f9e9
Pipeline #110 failed with stages
......@@ -4,3 +4,5 @@
.Ruserdata
.Rbuildignore
rvelov.Rproj
.Renviron
*.tar.gz
......@@ -2,9 +2,12 @@ FROM rocker/tidyverse:3.6.1
RUN R -e 'install.packages("remotes")'
RUN R -e 'remotes::install_github("r-lib/remotes", ref = "97bbf81")'
RUN R -e 'remotes::install_cran("shiny")'
RUN R -e 'remotes::install_cran("golem")'
RUN R -e 'remotes::install_github("Thinkr-open/golem")'
RUN R -e 'remotes::install_cran("htmltools")'
RUN R -e 'remotes::install_cran("pool")'
RUN R -e 'remotes::install_cran("ggplot2")'
COPY rvelov_*.tar.gz /app.tar.gz
COPY .Renviron /.Renviron
RUN R -e 'remotes::install_local("/app.tar.gz")'
EXPOSE 80
CMD R -e "options('shiny.port'=4848,shiny.host='0.0.0.0');rvelov::run_app()"
CMD R -e "options('shiny.port'=80,shiny.host='0.0.0.0');rvelov::run_app()"
......@@ -8,5 +8,4 @@ importFrom(data.table,":=")
importFrom(data.table,data.table)
importFrom(golem,with_golem_options)
importFrom(pool,dbPool)
importFrom(pool,poolClose)
importFrom(shiny,shinyApp)
#' @importFrom pool dbPool poolClose
app_global <- function() {
pool <- dbPool(
drv = RMySQL::MySQL(),
dbname = Sys.getenv("VELOV_DB"),
user = Sys.getenv("VELOV_USER"),
password = Sys.getenv("VELOV_PASSWORD"),
host = Sys.getenv("VELOV_HOST"),
port = as.numeric(Sys.getenv("VELOV_PORT")))
onStop(function() {
poolClose(pool)
})
}
......@@ -4,8 +4,23 @@
#' @importFrom shiny shinyApp
#' @importFrom golem with_golem_options
run_app <- function(...) {
with_golem_options(
app = shinyApp(ui = app_ui, server = app_server, onStart = app_global),
golem_opts = list(...)
)
pool <<- dbPool(
drv = RMySQL::MySQL(),
dbname = Sys.getenv("VELOV_DB"),
user = Sys.getenv("VELOV_USER"),
password = Sys.getenv("VELOV_PASSWORD"),
host = Sys.getenv("VELOV_HOST"),
port = as.numeric(Sys.getenv("VELOV_PORT")))
golem::with_golem_options(
app = shinyApp(ui = app_ui,
server = app_server,
onStart = function() {
onStop(function() {
poolClose(pool)
})
}),
golem_opts = list(...)
)
}
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