{"id":43605845,"url":"https://github.com/kyeotic/stack-sync","last_synced_at":"2026-02-21T02:06:50.107Z","repository":{"id":336383299,"uuid":"1148416968","full_name":"kyeotic/stack-sync","owner":"kyeotic","description":"A CLI to create and sync Docker Compose Stacks with ENV configs","archived":false,"fork":false,"pushed_at":"2026-02-19T06:54:40.000Z","size":212,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-19T12:41:18.903Z","etag":null,"topics":["portainer","rust","ssh-docker-compose"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kyeotic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-03T00:04:03.000Z","updated_at":"2026-02-19T06:55:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kyeotic/stack-sync","commit_stats":null,"previous_names":["kyeotic/stack-sync"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/kyeotic/stack-sync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyeotic%2Fstack-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyeotic%2Fstack-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyeotic%2Fstack-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyeotic%2Fstack-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyeotic","download_url":"https://codeload.github.com/kyeotic/stack-sync/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyeotic%2Fstack-sync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29671513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T00:11:43.526Z","status":"online","status_checked_at":"2026-02-21T02:00:07.432Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["portainer","rust","ssh-docker-compose"],"created_at":"2026-02-04T07:13:13.896Z","updated_at":"2026-02-21T02:06:50.102Z","avatar_url":"https://github.com/kyeotic.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stack-sync\n\nDeploy and manage Docker Compose stacks from the command line. Supports two deployment modes:\n\n- **Portainer mode** — Sync local Docker Compose files and environment variables to a [Portainer](https://www.portainer.io/) instance via its API\n- **SSH mode** — Push stacks directly to remote hosts via SSH and `docker compose`, targeting [dockge](https://github.com/louislam/dockge)-style setups or any host with Docker Compose installed\n\n## Prerequisites\n\n### Portainer mode\n- A Portainer instance with API access enabled\n- A `PORTAINER_API_KEY` (create one in Portainer under **User Settings \u003e Access Tokens**)\n\n### SSH mode\n- SSH access to the remote host (via key or agent)\n- `docker compose` installed on the remote host\n\n## Installation\n\n### With Homebrew (tap)\n\n```\nbrew install kyeotic/tap/stack-sync\n```\n\n### One-line Shell\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/kyeotic/stack-sync/main/install | bash\n```\n\n### With Nix Flakes\n\n```bash\nnix profile install github:kyeotic/stack-sync\n```\n\nOr download a binary from the [releases page](https://github.com/kyeotic/stack-sync/releases).\n\n## Quick Start\n\n### Portainer Mode (default)\n\n1. Create a `.stack-sync.toml` config file in your project directory:\n\n```toml\nhost = \"https://portainer.example.com\"\nendpoint_id = 2  # optional, default 2\nportainer_api_key = \"Your_Key\"\n\n[stacks.my-stack]\ncompose_file = \"compose.yaml\"\nenv_file = \".env\"  # optional\n\n[stacks.other-stack]\ncompose_file = \"other/compose.yaml\"\nenv_file = \"other/.env\"\nendpoint_id = 3  # optional per-stack override\n```\n\n| Field                     | Description                                       | Required |\n| ------------------------- | ------------------------------------------------- | -------- |\n| `host`                    | Portainer instance URL                            | Yes      |\n| `endpoint_id`             | Default Portainer environment/endpoint ID         | No       |\n| `stacks.\u003cname\u003e`           | Stack definition — the key is the stack name      | Yes      |\n| `compose_file`            | Path to the local Docker Compose file             | Yes      |\n| `env_file`                | Path to the local `.env` file for stack variables | No       |\n| `endpoint_id` (per-stack) | Override the top-level endpoint ID                | No       |\n\n### SSH Mode\n\n1. Create a `.stack-sync.toml` config file:\n\n```toml\nmode = \"ssh\"\nhost = \"192.168.0.20\"\nssh_user = \"root\"                # optional, defaults to current user\nssh_key = \"~/.ssh/id_ed25519\"    # optional, uses ssh-agent if omitted\nhost_dir = \"/mnt/app_config/docker\"\n\n[stacks.my-stack]\ncompose_file = \"compose.yaml\"\nenv_file = \".env\"  # optional\n```\n\n| Field      | Description                               | Required |\n| ---------- | ----------------------------------------- | -------- |\n| `mode`     | Set to `\"ssh\"` to enable SSH mode         | Yes      |\n| `host`     | SSH hostname or IP address                | Yes      |\n| `host_dir` | Remote directory where stacks are stored  | Yes      |\n| `ssh_user` | SSH username                              | No       |\n| `ssh_key`  | Path to SSH private key (`~` is expanded) | No       |\n\nStacks are deployed to `{host_dir}/{stack_name}/compose.yaml` on the remote host, with an optional `.env` file alongside it. This layout is compatible with [dockge](https://github.com/louislam/dockge) and similar tools.\n\nSSH mode shells out to the `ssh` command on your system, so it inherits your SSH agent, `~/.ssh/config`, and `known_hosts` automatically.\n\n### Deploy\n\n2. Deploy the stack:\n\n```bash\nstack-sync sync\n```\n\nThis creates or updates all stacks defined in the config. To target specific stacks:\n\n```bash\nstack-sync sync my-stack\nstack-sync sync my-stack other-stack\n```\n\n## Splitting Configuration\n\nSince creating a config file in your repo with secrets like the `portainer_api_key` is a bad practice, and since you're also likely to share the `host` with several projects, stack-sync supports config inheritance.\n\nGlobal fields (`host`, `portainer_api_key`, `endpoint_id`, `mode`, `ssh_user`, `ssh_key`, `host_dir`) can be provided by a `.stack-sync.toml` in any parent directory up to and including your `$HOME` directory. This allows connection settings to be stored outside the working directory.\n\nAlternatively you can provide a `PORTAINER_API_KEY` as an ENV VAR (e.g. sourced from a .env file by [dir-env](https://direnv.net/)) and not put it any config files.\n\nThe order of precedence is\n\n- `$PORTAINER_API_KEY` ENV VAR\n- current config (or config provided by `--config`)\n- The next parent directory\n\nConfigs can also be merged: if the parent directory config contains an `endpoint_id` and the `$HOME` directory config contains a `host` they will form a complete configuration.\n\n## Commands\n\n### sync\n\nCreate or update stacks using the local compose files and env vars.\n\n```bash\nstack-sync sync                            # sync all stacks\nstack-sync sync my-stack                   # sync one stack\nstack-sync sync my-stack other-stack       # sync specific stacks\nstack-sync sync my-stack --dry-run         # preview changes\nstack-sync sync -C /path/to/config.toml    # use a different config file\n```\n\nThe config path defaults to the current directory, where it will automatically look for `.stack-sync.toml` first, then `stack-sync.toml`. File paths in the config (`compose_file`, `env_file`) are resolved relative to the config file's directory, not the working directory.\n\n### view\n\nShow the current state of stacks on the remote.\n\n```bash\nstack-sync view                            # view all stacks\nstack-sync view my-stack                   # view one stack\nstack-sync view -C /path/to/config.toml    # use a different config file\n```\n\n### init\n\nInitialize config files for a new project. Creates a parent config with credentials/connection settings and a local config with an example stack.\n\n**Portainer mode** (default):\n\n```bash\nstack-sync init \\\n  --portainer-api-key ptr_xxx \\\n  --host https://portainer.example.com \\\n  --endpoint-id 2 \\\n  --parent-dir ~\n```\n\n**SSH mode:**\n\n```bash\nstack-sync init \\\n  --mode ssh \\\n  --host 192.168.0.20 \\\n  --host-dir /mnt/app_config/docker \\\n  --ssh-user root \\\n  --ssh-key ~/.ssh/id_ed25519 \\\n  --parent-dir ~\n```\n\n| Argument              | Description                                  | Required                |\n| --------------------- | -------------------------------------------- | ----------------------- |\n| `--mode`              | Deploy mode: `portainer` or `ssh`            | No (default: portainer) |\n| `--portainer-api-key` | Portainer API key                            | Portainer mode only     |\n| `--host`              | Portainer URL or SSH hostname                | Yes                     |\n| `--endpoint-id`       | Default endpoint ID (defaults to 2)          | No                      |\n| `--host-dir`          | Remote directory for stacks                  | SSH mode only           |\n| `--ssh-user`          | SSH username                                 | No                      |\n| `--ssh-key`           | Path to SSH private key                      | No                      |\n| `--parent-dir`        | Directory for credentials config (default ~) | No                      |\n| `--force`             | Overwrite existing files                     | No                      |\n\nThis creates two files:\n- `{parent-dir}/.stack-sync.toml` — credentials/connection settings\n- `./.stack-sync.toml` — local config with example stack commented out\n\n### import\n\nImport an existing stack from Portainer (or a remote SSH host) into your local config. Downloads the compose file and env vars, and adds the stack to your config.\n\n```bash\nstack-sync import my-stack                    # import a stack\nstack-sync import my-stack --force            # overwrite existing files\nstack-sync import my-stack -C /path/to/dir    # use a different config directory\n```\n\n| Argument  | Description                      | Required |\n| --------- | -------------------------------- | -------- |\n| `\u003cstack\u003e` | Name of the stack to import      | Yes      |\n| `-C`      | Path to config file or directory | No       |\n| `--force` | Overwrite existing files         | No       |\n\nCreates `{stack}.compose.yaml` and `{stack}.env` files, and adds a `[stacks.{stack}]` entry to the local config. In SSH mode, the stack is read from `{host_dir}/{stack}/compose.yaml` on the remote host.\n\n### redeploy\n\nForce a stack to re-pull images and redeploy. Useful after pushing new images to a registry. In Portainer mode, this uses the current configuration from Portainer (not local files). In SSH mode, it runs `docker compose pull \u0026\u0026 docker compose up -d --force-recreate` on the remote host.\n\n```bash\nstack-sync redeploy my-stack                   # redeploy a stack\nstack-sync redeploy my-stack --dry-run         # preview what would happen\nstack-sync redeploy my-stack -C /path/to/dir   # use a different config directory\n```\n\n| Argument    | Description                      | Required |\n| ----------- | -------------------------------- | -------- |\n| `\u003cstack\u003e`   | Name of the stack to redeploy    | Yes      |\n| `-C`        | Path to config file or directory | No       |\n| `--dry-run` | Preview without making changes   | No       |\n\nThe stack must exist in both the local config and on the remote (Portainer or SSH host).\n\n### upgrade\n\nCheck for the latest release and update the binary in-place.\n\n```bash\nstack-sync upgrade\n```\n\n\u003e **Note:** Self-update is not supported when installed via Nix. Use `nix profile upgrade --flake github:kyeotic/stack-sync` instead.\n\n## Env File Format\n\nThe `.env` file uses standard `KEY=value` format:\n\n```\nDATABASE_URL=postgres://localhost:5432/mydb\nAPI_KEY=sk-abc123\nDEBUG=true\n```\n\nLines starting with `#` and blank lines are ignored.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyeotic%2Fstack-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyeotic%2Fstack-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyeotic%2Fstack-sync/lists"}