-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from shizunge/readme
Add pre and post run cmd. Find self service name automatically. Excluding update time from sleep time.
- Loading branch information
Showing
16 changed files
with
246 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Examples | ||
|
||
## [cronjob](./cronjob) | ||
|
||
Run *gantry* at the specific time. | ||
|
||
## [prune-and-watchtower](./prune-and-watchtower) | ||
|
||
Remove unused containers, networks and images. Update standalone docker containers. Update docker swarm services. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# cronjob | ||
|
||
Use [*swarm-cronjob*](https://github.com/crazy-max/swarm-cronjob) to launch *gantry* at a given time. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# prune and watchtower | ||
|
||
This example runs `docker system prune` and *watchtower* before updating docker swarm services. | ||
|
||
* [`docker system prune`](https://docs.docker.com/engine/reference/commandline/system_prune/) removes all unused containers, networks and images. | ||
* [*watchtower*](https://github.com/containrrr/watchtower) updates standalone docker containers. | ||
* [*gantry*](https://github.com/shizunge/gantry) updates docker swarm services. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: "3.8" | ||
|
||
services: | ||
gantry: | ||
image: shizunge/gantry | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
environment: | ||
- "GANTRY_NODE_NAME={{.Node.Hostname}}" | ||
- "GANTRY_PRE_RUN_CMD=SERVICE_NAME=gantry-prune; | ||
docker service remove $${SERVICE_NAME} 2>/dev/null; | ||
docker service create --mode global-job --name $${SERVICE_NAME} | ||
--mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock | ||
--entrypoint docker | ||
alpinelinux/docker-cli | ||
system prune -f; | ||
docker service logs $${SERVICE_NAME}; | ||
docker service remove $${SERVICE_NAME}; | ||
SERVICE_NAME=gantry-container; | ||
docker service remove $${SERVICE_NAME} 2>/dev/null; | ||
docker service create --mode global-job --name $${SERVICE_NAME} | ||
--mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock | ||
ghcr.io/containrrr/watchtower | ||
--cleanup=true | ||
--label-enable | ||
--run-once=true | ||
--stop-timeout=60s | ||
--tlsverify=true; | ||
docker service logs $${SERVICE_NAME}; | ||
docker service remove $${SERVICE_NAME}; | ||
" | ||
- "GANTRY_POST_RUN_CMD=echo \"This is a post run command.\";" | ||
- "GANTRY_SLEEP_SECONDS=0" | ||
deploy: | ||
replicas: 0 | ||
placement: | ||
constraints: | ||
- node.role==manager | ||
restart_policy: | ||
condition: none | ||
labels: | ||
- swarm.cronjob.enable=true | ||
- swarm.cronjob.schedule=45 23 0 * * * | ||
- swarm.cronjob.skip-running=true | ||
|
||
cronjob: | ||
image: crazymax/swarm-cronjob:latest | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
deploy: | ||
placement: | ||
constraints: | ||
- node.role==manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.