0

I'm using drake to orchestrate a workflow where if an external shiny app (stored in project_dir/shiny/app.R) changes, I want to trigger a docker build.

shiny_plan <- drake_plan(

  docker_build = system(command = "docker build shiny/. -t docker.com/my-dash")

)

How do I detect a change in app.R to trigger target docker_build, given that drake does not help create app.R?

Best

Rahul
  • 2,579
  • 1
  • 13
  • 22
  • 1
    Update: you may be interested in dynamic files: https://github.com/ropensci/drake/pull/1178. Brand new in development `drake` (the GitHub version, `remotes::install_github("ropensci/drake")). – landau Feb 22 '20 at 13:32

1 Answers1

3

You can put a file_in() wherever you want.

shiny_plan <- drake_plan(
  docker_build = {
    file_in("app.R")
    system(command = "docker build shiny/. -t docker.com/my-dash")
  }
)

Alternatively, you could make the Docker build depend on the UI and server objects. That way, Docker will not trigger unnecessarily if all you do is change the comments or whitespace in your app code.

shiny_plan <- drake_plan(
  docker_build = {
    ui
    server
    system(command = "docker build shiny/. -t docker.com/my-dash")
  }
)
landau
  • 5,636
  • 1
  • 22
  • 50