-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
220 lines (195 loc) · 6.42 KB
/
Copy pathTaskfile.yml
File metadata and controls
220 lines (195 loc) · 6.42 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
version: '3'
dotenv:
- .env
tasks:
default:
desc: List available tasks
cmds:
- task --list
setup:
desc: Install dependencies without overwriting config or data
cmds:
- |
set -eu
if [ ! -f .env ]; then
install -m 0600 .env.example .env
printf '%s\n' \
'setup: created .env; review all credentials before deployment'
else
printf '%s\n' 'setup: .env exists, leaving it untouched'
fi
npm ci
(cd backend && go mod download)
doctor:
desc: Run read-only environment checks (MODE=runtime|ci)
cmds:
- ./scripts/doctor.sh "{{.MODE}}"
dev:
desc: Start the frontend and backend in the foreground
cmds:
- task --parallel frontend backend
frontend:
desc: Start the Vite development server
cmds:
- npm run dev
backend:
desc: Build and start the local PocketBase extension
cmds:
- |
cd backend
CGO_ENABLED=0 GOOS=linux go build -tags nocgo \
-o ebook-pocketbase ./cmd/ebook-pocketbase
PUBLIC_DIR=../dist ./ebook-pocketbase serve \
--http="${POCKETBASE_HOST:-127.0.0.1}:${POCKETBASE_PORT:-8090}" \
--dir "${POCKETBASE_DATA_DIR:-../.local/pb_data}" \
--hooksDir ../pb_hooks
bootstrap:
desc: Create the local PocketBase collections and demo users
cmds:
- node scripts/bootstrap-pocketbase.mjs
stop:
desc: Explain how to stop foreground development processes
cmds:
- |
printf '%s\n' \
'NOT_APPLICABLE task=stop reason=dev-runs-in-foreground-use-signal'
exit 4
status:
desc: Check local frontend and backend endpoints
cmds:
- |
set +e
rc=0
frontend_url="http://${FRONTEND_HOST:-127.0.0.1}:${FRONTEND_PORT:-5173}"
backend_url="http://${POCKETBASE_HOST:-127.0.0.1}:${POCKETBASE_PORT:-8090}"
printf 'frontend: %s\n' "$frontend_url"
curl -fsS --max-time 3 "$frontend_url" >/dev/null || rc=1
printf 'backend: %s/api/health\n' "$backend_url"
curl -fsS --max-time 3 "$backend_url/api/health" >/dev/null || rc=1
exit "$rc"
logs:
desc: Explain foreground development log handling
cmds:
- |
printf '%s\n' \
'NOT_APPLICABLE task=logs reason=dev-logs-stream-to-foreground'
exit 4
fmt:
desc: Format frontend, configuration, and Go sources
cmds:
- npm run format
- gofmt -w backend
fmt:check:
desc: Check formatting without modifying files
cmds:
- npm run format:check
- |
unformatted="$(gofmt -l backend)"
if [ -n "$unformatted" ]; then
printf 'GOFMT_REQUIRED\n%s\n' "$unformatted" >&2
exit 1
fi
lint:
desc: Run frontend, shell, and Go linters
cmds:
- npm run lint
- shellcheck scripts/*.sh
- cd backend && go vet ./...
typecheck:
desc: Run frontend type checking
cmds:
- npm run typecheck
test:
desc: Run data path, frontend, and backend tests
cmds:
- ./scripts/test-data-path.sh
- npm test
- cd backend && go test ./...
build:
desc: Build frontend and backend artifacts
cmds:
- npm run build
- |
mkdir -p .local/go-build-cache
cd backend
GOCACHE="$PWD/../.local/go-build-cache" CGO_ENABLED=0 GOOS=linux go build -tags nocgo \
-o ebook-pocketbase ./cmd/ebook-pocketbase
config:
desc: Validate manifest and merged Compose configuration
cmds:
- node scripts/validate-config.mjs
check:
desc: Run ordered, side-effect-free project checks
cmds:
- task doctor MODE=ci
- task fmt:check
- task lint
- task typecheck
- task test
- task build
- task config
deploy:
desc: Deploy incremental frontend/backend changes
cmds:
- ./scripts/deploy-fast.sh
deploy:verify:
desc: Check and deploy the application with Compose v2
cmds:
- task check
- task deploy:image
deploy:image:
desc: Build the application image and start it with Compose v2
cmds:
- |
data_path="$(./scripts/resolve-data-path.sh)"
builder_cache_path="${DOCKER_BUILDER_CACHE_PATH:-./.local/docker-build-cache}"
mkdir -p "$data_path/tmp" "$builder_cache_path"
chmod 0750 "$data_path" "$builder_cache_path"
chmod 1777 "$data_path/tmp"
if ! docker network inspect cicd-observability >/dev/null 2>&1; then
printf '%s\n' \
'DEPENDENCY_MISSING network=cicd-observability run=cicd-setup' >&2
exit 3
fi
DOCKER_PB_DATA_PATH="$data_path" \
DOCKER_BUILDER_CACHE_PATH="$builder_cache_path" \
docker compose -p ebook-reader-uzqw \
-f compose.yaml -f compose.build.yaml \
-f compose.observability.yaml config --quiet
DOCKER_PB_DATA_PATH="$data_path" \
DOCKER_BUILDER_CACHE_PATH="$builder_cache_path" \
docker compose -p ebook-reader-uzqw \
-f compose.yaml -f compose.build.yaml \
-f compose.observability.yaml up -d --build --force-recreate
deploy:down:
desc: Stop the deployment without deleting persistent data
cmds:
- |
data_path="$(./scripts/resolve-data-path.sh)"
builder_cache_path="${DOCKER_BUILDER_CACHE_PATH:-./.local/docker-build-cache}"
DOCKER_PB_DATA_PATH="$data_path" \
DOCKER_BUILDER_CACHE_PATH="$builder_cache_path" \
docker compose -p ebook-reader-uzqw \
-f compose.yaml -f compose.build.yaml \
-f compose.observability.yaml down
deploy:logs:
desc: Show deployment logs (FOLLOW=1, TAIL=n)
cmds:
- |
data_path="$(./scripts/resolve-data-path.sh)"
builder_cache_path="${DOCKER_BUILDER_CACHE_PATH:-./.local/docker-build-cache}"
follow_arg=
[ "${FOLLOW:-0}" != 1 ] || follow_arg=--follow
DOCKER_PB_DATA_PATH="$data_path" \
DOCKER_BUILDER_CACHE_PATH="$builder_cache_path" \
docker compose -p ebook-reader-uzqw \
-f compose.yaml -f compose.build.yaml \
-f compose.observability.yaml logs \
--tail "${TAIL:-100}" $follow_arg
clean:
desc: Remove only regenerable build and cache artifacts
cmds:
- |
rm -rf -- dist node_modules/.vite node_modules/.cache
rm -f -- backend/ebook-pocketbase
printf '%s\n' 'clean: removed build outputs and tool caches'