Skip to content

allow to run without git repo #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
36 changes: 26 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

/// 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,
},
Expand Down Expand Up @@ -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);
}
}
Expand Down