About therun_app() function
When launching the app, you might have noticed that thedev/run_dev.R function callsrun_app(), whichhas the following structure:
run_app<-function(...){with_golem_options( app=shinyApp( ui=app_ui, server=app_server), golem_opts=list(...))}This function might look a little bit weird, but there’s a long storybehind it, and you can read more about itthere.
But long story short, this combination ofwith_golem_options &golem_opts = list(...) allows you to pass arguments to thefunction to be used inside the application, from UI or from server side,which you can get withget_golem_options().
run_app(this="that")# And in the appthis<-get_golem_options("this")The idea is to provide more flexibility for deployment on eachplatform you want to run your app on.
Deploying Apps with{golem}
Thedev/03_deploy.R file contains functions fordeployment on various platforms.
Posit Products
golem::add_positconnect_file()golem::add_shinyappsio_file()golem::add_shinyserver_file()For Git backed deployment on Posit (fordetailsamanifest.json file is required which can be added (orupdated) via:
rsconnect::writeManifest()Docker
Without using{renv}
# If you want to deploy via a generic Dockerfilegolem::add_dockerfile()# If you want to deploy to ShinyProxygolem::add_dockerfile_shinyproxy()# If you want to deploy to Herokugolem::add_dockerfile_heroku()Using{renv} - CASE 1 : you didn’t use renv duringdevelopment process
this functions will create a “deploy” folder containing :
deploy/+-- Dockerfile+-- Dockerfile_base+-- yourgolem_0.0.0.9000.tar.gz+-- README\-- renv.lock.prodthen follow theREADME file.
# If you want to deploy via a generic Dockerfilegolem::add_dockerfile_with_renv(output_dir="deploy")# If you want to deploy to ShinyProxygolem::add_dockerfile_with_renv_shinyproxy(output_dir="deploy")If you would like to userenv during development, youcan init arenv.lock file with
attachment::create_renv_for_dev(dev_pkg=c("renv","devtools","roxygen2","usethis","pkgload","testthat","remotes","covr","attachment","pak","dockerfiler","golem"))and activaterenv with
renv::activate()Using{renv} - CASE 2: you already have arenv.lock file for your project
# If you want to deploy via a generic Dockerfilegolem::add_dockerfile_with_renv(output_dir="deploy", lockfile="renv.lock")# If you want to deploy to ShinyProxygolem::add_dockerfile_with_renv_shinyproxy(output_dir="deploy", lockfile="renv.lock")this functions will create a “deploy” folder containing :
deploy/+-- Dockerfile+-- Dockerfile_base+-- yourgolem_0.0.0.9000.tar.gz+-- README\-- renv.lock.prodthen follow theREADME file.