run_app()
functionWhen launching the app, you might have noticed that the
dev/run_dev.R
function calls run_app()
, which
has the following structure:
<- function(
run_app
...
) {with_golem_options(
app = shinyApp(
ui = app_ui,
server = app_server
), golem_opts = list(...)
) }
This function might looks a little bit weird, but there’s a long story behind it, and you can read more about it there.
But long story short, this combination of
with_golem_options
&
golem_opts = list(...)
allows you to pass argument to the
function to be used inside the application, from UI or from server side,
which you can get with get_golem_options()
.
run_app(this = "that")
# And in the app
<- get_golem_options("this") this
The idea is to provide more flexibility for deployment on each platform you want to run your app on.
{golem}
The dev/03_deploy.R
file contains function for deploying
on various platforms.
::add_rstudioconnect_file()
golem::add_shinyappsio_file()
golem::add_shinyserver_file() golem
# If you want to deploy via a generic Dockerfile
::add_dockerfile()
golem
# If you want to deploy to ShinyProxy
::add_dockerfile_shinyproxy()
golem
# If you want to deploy to Heroku
::add_dockerfile_heroku() golem
this functions will create a “deploy” folder containing :
deploy/
+-- Dockerfile
+-- Dockerfile_base
+-- yourgolem_0.0.0.9000.tar.gz
+-- README \-- renv.lock.prod
then follow the README file
# If you want to deploy via a generic Dockerfile
::add_dockerfile_with_renv(output_dir = "deploy")
golem
# If you want to deploy to ShinyProxy
::add_dockerfile_with_renv_shinyproxy(output_dir = "deploy") golem
If you would like to use {renv} during developpement, you can init a renv.lock file with
::create_renv_for_dev(dev_pkg = c("renv", "devtools", "roxygen2",
attachment"usethis", "pkgload", "testthat", "remotes", "covr", "attachment",
"pak", "dockerfiler","golem"))
an activate {renv} with
::activate() renv
# If you want to deploy via a generic Dockerfile
::add_dockerfile_with_renv(output_dir = "deploy",lockfile = "renv.lock")
golem
# If you want to deploy to ShinyProxy
::add_dockerfile_with_renv_shinyproxy(output_dir = "deploy",lockfile = "renv.lock") golem
this functions will create a “deploy” folder containing :
deploy/
+-- Dockerfile
+-- Dockerfile_base
+-- yourgolem_0.0.0.9000.tar.gz
+-- README \-- renv.lock.prod
then follow the README file