#' Run app locally
#'
#' @export
run_local <- function() {
options(golem.app.prod = TRUE)
golem::detach_all_attached()
golem::document_and_reload()
turtleviewer::run_app()
}
#' Build and push Docker images
#'
#' @export
make_docker <- function() {
message("Deleting old package build...")
fs::dir_ls(".", glob = "*.tar.gz") %>% fs::file_delete()
message("Building current package...")
devtools::build(path = ".")
message("Building and pushing Docker image...")
system(
glue::glue(
"docker build . -t dbcawa/turtleviewer ",
"-t dbcawa/turtleviewer:{packageVersion('turtleviewer')} &&",
"docker push dbcawa/turtleviewer"
)
)
message(
glue::glue(
"Success, pushed dbcawa/turtleviewer:{packageVersion('turtleviewer')}"
)
)
}
#' Copy cmd to transfer media files from local to prod to clipboard
#'
#' Add to .Renviron: `CLIPR_ALLOW=TRUE`
#'
#' @export
rsync_cmd_to_clipboard <- function() {
# Run in source system (local laptop) - use VPN if offsite:
ip <- system(
"ifconfig -a | grep ppp0 -A 1 | grep inet | gawk '{print $2}'",
intern = T
)
# Run in target system (deployed container on rks.dbca.wa.gov.au):
glue::glue(
"rsync -Pavvr ",
"florian@{ip}:/home/florian/projects/turtleviewer/inst/odk/ ",
"/usr/local/lib/R/site-library/turtleviewer/odk/"
) %>%
clipr::write_clip()
message("Command pasted to clipboard: rsync ODK data to server")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.