Start and stop (delete) docker compose projects on demand through traefik. Heavily inspired by sablier.
- Clone the repository
- Build the container
- Add to your static traefik config:
experimental:
localPlugins:
compose_scaler:
moduleName: "github.com/t348575/compose-scaler"
- Mount the repo path to the traefik container:
- /path/to/repo/compose-scaler:/plugins-local/src/github.com/t348575/compose-scaler
- Sample docker compose config:
version: '3'
services:
compose-scaler:
container_name: compose-scaler
image: compose-scaler
# port to listen on, config file path
command: ["-a", "0.0.0.0:10000", "-c", "/config.yaml"]
volumes:
# uses docker socket to get container health / status
- /var/run/docker.sock:/var/run/docker.sock
# path to public & private key for ssh-ing back to host
- /home/my_user/.ssh/compose_scaler_key.pub:/compose_scaler_key.pub:ro
- /home/my_user/.ssh/compose_scaler_key:/compose_scaler_key:ro
# compose-scaler config file
- ./compose-scaler.yaml:/config.yaml:ro
- Sample compose-scaler config:
ssh_host: my_host:22
ssh_username: my_user
projects_dir: /path/on/host/to/compose/projects
public_key: /compose_scaler_key.pub
private_key: /compose_scaler_key
initial_projects:
- gitea
- dockge
- obsidian-zola
- obsidian-livesync
- overleaf
- any_other_project
- Expected compose projects directory structure:
├── my_project_dir
│ ├── gitea
| | ├── docker-compose.yaml
│ ├── dockge
| | ├── docker-compose.yaml
│ ├── overleaf
| | ├── anything_inside
- Sample traefik middleware config:
http:
middlewares:
dockge_cs:
plugin:
compose_scaler:
name: dockge # this must match the folder name inside your compose projects directory
displayName: Dockge # displayed on the waiting page
refreshFrequency: 5s # how often to refresh status, etc.
theme: ghost # theme for waiting page
composeScalerUrl: http://compose-scaler:10000 # compose-scaler uri
sessionDuration: 5m # time before running docker compose down
# if required, pass a path to a custom docker compose, eg. overleaf uses one
# the default is "docker compose"
customCommand: bin/docker-compose