diff --git a/README.md b/README.md index ad70ef6..ef7c3ce 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,15 @@ ssh into your docker host and run `docker restart docker-stack-deploy`. That will cause it to pull the repo immediately and run through the deploy commands. +## How do I deploy without local directory without a git repo? + +If you don't want to use git repos, you can run the following command. Set +`--poll-interval` to 0 to disable the polling. + +```console +docker-stack-deploy run --repo-dir=/path/to/your/stacks --poll-interval=0 +``` + ## Troubleshooting You can use `docker compose ls` to review the stacks that are running. diff --git a/src/main.rs b/src/main.rs index 1ce8b38..e2ae030 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,11 +60,11 @@ enum Command { #[arg(long)] repo_dir: String, - /// URL from which the repo should be cloned + /// URL from which the repo should be cloned if provided #[arg(long)] - repo_url: String, + repo_url: Option, - /// How many seconds to wait between checking the repo for updates + /// How many seconds to wait between checking the repo for updates. 0 to disable. #[arg(long, default_value = "300")] poll_interval: u64, }, @@ -240,15 +240,31 @@ fn main() -> anyhow::Result<()> { let mut first_run = true; loop { - let hash = clone_or_update(repo_url, repo_dir)?; - log::debug!("hash is {hash:?}"); - if hash.updated() || first_run { - log::info!("Running a deploy {hash:?}"); - if let Err(err) = run_deploy(&args, repo_dir) { - log::error!("Error running deploy: {err:#}"); + match repo_url { + Some(repo_url) => { + let hash = clone_or_update(repo_url, repo_dir)?; + log::debug!("hash is {hash:?}"); + if hash.updated() || first_run { + log::info!("Running a deploy {hash:?}"); + if let Err(err) = run_deploy(&args, repo_dir) { + log::error!("Error running deploy: {err:#}"); + } + } + first_run = false; } + None => { + log::info!("Running a deploy"); + if let Err(err) = run_deploy(&args, repo_dir) { + log::error!("Error running deploy: {err:#}"); + } + } + } + + // Disable polling if the interval is 0 + if *poll_interval == 0 { + break; } - first_run = false; + std::thread::sleep(interval); } }