-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
74 lines (66 loc) · 2.06 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
version: '3'
# Global variables
vars:
DOCKER_COMPOSE_FILE: "./docker/docker-compose.yml"
tasks:
default:
desc: "Show available Docker tasks"
cmds:
- task --list
up:
desc: "Start all services with Docker Compose"
cmds:
- echo "Starting all services..."
- docker-compose -f {{.DOCKER_COMPOSE_FILE}} up -d
down:
desc: "Stop all services with Docker Compose"
cmds:
- echo "Stopping all services..."
- docker-compose -f {{.DOCKER_COMPOSE_FILE}} down
rebuild:
desc: "Rebuild and restart services with Docker Compose"
cmds:
- task down
- echo "Rebuilding services..."
- docker-compose -f {{.DOCKER_COMPOSE_FILE}} build
- task up
logs:
desc: "View logs from Docker Compose services"
cmds:
- docker-compose -f {{.DOCKER_COMPOSE_FILE}} logs -f
clean:
desc: "Clean up unused Docker resources"
cmds:
- echo "Cleaning up unused Docker resources..."
- docker-compose -f {{.DOCKER_COMPOSE_FILE}} down --volumes --remove-orphans
- docker system prune -f --volumes
clean-all:
desc: "Delete all Docker objects including images, containers, volumes, and networks"
cmds:
- echo "Stopping all running containers..."
- |
docker ps -q | while read -r container; do
docker stop "$container";
done
- echo "Removing all containers..."
- |
docker ps -aq | while read -r container; do
docker rm "$container";
done
- echo "Removing all images..."
- |
docker images -q | while read -r image; do
docker rmi -f "$image";
done
- echo "Removing all volumes..."
- |
docker volume ls -q | while read -r volume; do
docker volume rm "$volume";
done
- echo "Removing all networks (except default)..."
- |
docker network ls --filter "type=custom" -q | while read -r network; do
docker network rm "$network";
done
- echo "Pruning unused Docker objects..."
- docker system prune -af --volumes