container-server/tasks/compose.yml

86 lines
1.9 KiB
YAML
Raw Normal View History

version: '3'
includes:
util:
taskfile: ./utils.yml
internal: true
dir: ..
vars:
COMPOSE_FILES:
sh: touch enabled ; find ./services -iname docker-compose.yml | grep -f enabled || exit 0
COMPOSE_ARGS: -f services/docker-compose.yml -f {{.COMPOSE_FILES | splitLines | join " -f "}}
tasks:
show:
desc: Show merged compose config
deps:
- util:template
cmds:
- "docker-compose {{.COMPOSE_ARGS}} config"
pull:
desc: Pull latest docker images
cmds:
- "docker-compose {{.COMPOSE_ARGS}} pull {{.CLI_ARGS}}"
build:
desc: Build latest docker images (if applicable)
cmds:
- "docker-compose {{.COMPOSE_ARGS}} build {{.CLI_ARGS}}"
up:
desc: Deploy given or active services
deps:
- util:template
cmds:
- "docker-compose {{.COMPOSE_ARGS}} up -d {{.CLI_ARGS}}"
restart:
desc: Restart given or active services
deps:
- util:template
cmds:
- "docker-compose {{.COMPOSE_ARGS}} restart {{.CLI_ARGS}}"
recreate:
desc: Recreate given or active services
deps:
- util:template
cmds:
2023-09-09 16:01:23 +02:00
- "docker-compose {{.COMPOSE_ARGS}} up -d --force-recreate {{.CLI_ARGS}}"
stop:
desc: Stop given or all services
cmds:
- "docker-compose {{.COMPOSE_ARGS}} stop {{.CLI_ARGS}}"
down:
desc: Stop and remove all services
cmds:
- "docker-compose {{.COMPOSE_ARGS}} down"
logs:
desc: Tail logs of given or all services
deps:
- util:template
cmds:
- "docker-compose {{.COMPOSE_ARGS}} logs --tail=50 --follow {{.CLI_ARGS}}"
upgrade:
desc: Pull and re-deploy active services
cmds:
- task: pull
- task: up
list:
desc: List current containers
cmds:
- docker ps -a --format 'table {{"{{.ID}}"}}\t{{"{{.Image}}"}}\t{{"{{.Names}}"}}\t{{"{{.CreatedAt}}"}}\t{{"{{.Status}}"}}\t{{"{{.Networks}}"}}'
2023-02-18 15:25:31 +01:00
uplogs:
desc: up & logs
cmds:
- task: up
- task: logs