-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
87 lines (73 loc) · 2.24 KB
/
Taskfile.yml
File metadata and controls
87 lines (73 loc) · 2.24 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
# https://taskfile.dev
version: '3'
vars:
GOOS: "{{default OS .GOOS}}"
MVNW: '{{ if eq .GOOS "windows"}}mvnw.cmd{{else}}./mvnw{{end}}'
DC_DIR: "deployment/docker-compose"
INFRA_DC_FILE: "{{.DC_DIR}}/infra.yml"
APPS_DC_FILE: "{{.DC_DIR}}/apps.yml"
tasks:
default:
cmds:
- task: test
test:
deps: [format]
cmds:
- "{{.MVNW}} clean verify"
format:
cmds:
- "{{.MVNW}} spotless:apply"
build:
cmds:
- "{{.MVNW}} -pl catalog-service spring-boot:build-image -DskipTests"
start_infra:
cmds:
- docker compose -f "{{.INFRA_DC_FILE}}" up -d
stop_infra:
cmds:
- docker compose -f "{{.INFRA_DC_FILE}}" stop
- docker compose -f "{{.INFRA_DC_FILE}}" rm -f
restart_infra:
cmds:
- task: stop_infra
- task: sleep
- task: start_infra
start_using_dockerHub_image:
cmds:
- docker run -d --name catalog-db -p 127.0.0.1:15432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres:17.4-alpine3.21
- task: sleep
vars:
DURATION: 10
- docker run -d --name catalog-service -p 127.0.0.1:8081:8081 -e SPRING_PROFILES_ACTIVE=docker -e DB_URL=jdbc:postgresql://host.docker.internal:15432/postgres -e DB_USERNAME=postgres -e DB_PASSWORD=postgres heymaaz/bookstore-catalog-service:latest
- echo "Services started! Access API at http://localhost:8081/api/products"
stop_using_dockerHub_image:
cmds:
- docker stop catalog-service catalog-db
- docker rm catalog-service catalog-db
- echo "All services stopped and removed"
restart_using_dockerHub_image:
cmds:
- task: stop_using_dockerHub_image
- task: sleep
vars:
DURATION: 10
- task: start_using_dockerHub_image
start:
deps: [build]
cmds:
- docker compose -f "{{.INFRA_DC_FILE}}" -f "{{.APPS_DC_FILE}}" up -d
stop:
cmds:
- docker compose -f "{{.INFRA_DC_FILE}}" -f "{{.APPS_DC_FILE}}" stop
- docker compose -f "{{.INFRA_DC_FILE}}" -f "{{.APPS_DC_FILE}}" rm -f
restart:
cmds:
- task: stop
- task: sleep
- task: start
sleep:
vars:
DURATION: '{{ default 5 .DURATION}}'
cmds:
- echo 'sleeping for {{.DURATION}}s'
- sleep '{{.DURATION}}'