-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
88 lines (77 loc) · 2.21 KB
/
Copy pathTaskfile.yml
File metadata and controls
88 lines (77 loc) · 2.21 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
version: "3"
# Automatically load environment variables
dotenv: [".env.local", ".env"]
vars:
SRH_NAME: '{{.SRH_NAME | default "sw-srh"}}'
SRH_IMAGE: '{{.SRH_IMAGE | default "hiett/serverless-redis-http:latest"}}'
SRH_PORT: "{{.SRH_PORT | default 8080}}"
tasks:
env-setup:
desc: "Create .env.local interactively"
vars:
# Map Windows_NT to windows, otherwise use the OS as is
TARGET: '{{if eq .OS "Windows_NT"}}windows{{else}}{{.OS}}{{end}}'
cmds:
- task: env-setup:{{.TARGET}}
env-setup:windows:
internal: true
platforms: [windows]
cmds:
- powershell -NoProfile -ExecutionPolicy Bypass -File ./scripts/setup-env.ps1
env-setup:linux: &posix
internal: true
platforms: [linux]
cmds:
- sh ./scripts/setup-env.sh
env-setup:darwin:
<<: *posix
platforms: [darwin]
dev:
desc: "Start development environment"
deps: [ensure-srh]
cmds:
- npm run dev
ensure-srh:
desc: "Start SRH container if not running"
# Only run if the container isn't already active
status:
- sh: test -n "$(docker ps --filter 'name={{.SRH_NAME}}' --filter 'status=running' -q)"
cmds:
- |
docker start "{{.SRH_NAME}}" 2>/dev/null || \
( \
envfile=$(mktemp) && \
trap 'rm -f "$envfile"' EXIT && \
printf '%s\n' \
'SRH_MODE=env' \
"SRH_TOKEN={{.SRH_TOKEN}}" \
"SRH_CONNECTION_STRING={{.SRH_CONNECTION_STRING}}" \
"SRH_EMAIL={{.EMAIL}}" \
> "$envfile" && \
docker run -d -p "{{.SRH_PORT}}:80" --name "{{.SRH_NAME}}" --env-file "$envfile" "{{.SRH_IMAGE}}" \
)
wait-for-srh:
internal: true
desc: "Health check for SRH"
cmds:
- |
i=1
while [ "$i" -le 30 ]; do
if curl -s "http://localhost:{{.SRH_PORT}}/" > /dev/null; then
echo "SRH is up."
exit 0
fi
sleep 1
i=$((i + 1))
done
echo "SRH failed to start." >&2
exit 1
stop-srh:
desc: "Stop and remove SRH"
cmds:
- docker rm -f {{.SRH_NAME}}
ignore_error: true
logs-srh:
desc: "Tail SRH logs"
cmds:
- docker logs -f {{.SRH_NAME}}