Add phaseflow-cron job and PocketBase admin credentials
- New periodic job for daily Garmin sync at 6 AM - Added pocketbase_admin_email and pocketbase_admin_password to secrets template for cron job authentication Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
42
services/phaseflow-cron.hcl
Normal file
42
services/phaseflow-cron.hcl
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# ABOUTME: Periodic batch job for PhaseFlow Garmin sync.
|
||||||
|
# ABOUTME: Triggers daily sync at 6 AM to fetch fitness data and generate training recommendations.
|
||||||
|
|
||||||
|
job "phaseflow-cron" {
|
||||||
|
datacenters = ["alo"]
|
||||||
|
type = "batch"
|
||||||
|
|
||||||
|
periodic {
|
||||||
|
crons = ["0 6 * * *"]
|
||||||
|
prohibit_overlap = true
|
||||||
|
time_zone = "Europe/Lisbon"
|
||||||
|
}
|
||||||
|
|
||||||
|
group "garmin-sync" {
|
||||||
|
task "trigger" {
|
||||||
|
driver = "raw_exec"
|
||||||
|
|
||||||
|
config {
|
||||||
|
command = "/bin/sh"
|
||||||
|
args = ["local/script.sh"]
|
||||||
|
}
|
||||||
|
|
||||||
|
template {
|
||||||
|
destination = "local/script.sh"
|
||||||
|
data = <<EOH
|
||||||
|
set -e
|
||||||
|
/run/current-system/sw/bin/curl -s -f -X POST \
|
||||||
|
-H "Authorization: Bearer $CRON_SECRET" \
|
||||||
|
https://phaseflow.v.paler.net/api/cron/garmin-sync
|
||||||
|
EOH
|
||||||
|
}
|
||||||
|
|
||||||
|
template {
|
||||||
|
destination = "secrets/env.env"
|
||||||
|
env = true
|
||||||
|
data = <<EOH
|
||||||
|
{{- with nomadVar "secrets/phaseflow" -}}CRON_SECRET="{{ .cron_secret }}"{{- end -}}
|
||||||
|
EOH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,9 @@
|
|||||||
# nomad var put secrets/phaseflow \
|
# nomad var put secrets/phaseflow \
|
||||||
# resend_api_key="re_xxxx" \
|
# resend_api_key="re_xxxx" \
|
||||||
# encryption_key="$(openssl rand -hex 16)" \
|
# encryption_key="$(openssl rand -hex 16)" \
|
||||||
# cron_secret="$(openssl rand -hex 32)"
|
# cron_secret="$(openssl rand -hex 32)" \
|
||||||
|
# pocketbase_admin_email="admin@example.com" \
|
||||||
|
# pocketbase_admin_password="your-admin-password"
|
||||||
|
|
||||||
job "phaseflow" {
|
job "phaseflow" {
|
||||||
datacenters = ["alo"]
|
datacenters = ["alo"]
|
||||||
@@ -66,7 +68,6 @@ job "phaseflow" {
|
|||||||
tags = [
|
tags = [
|
||||||
"traefik.enable=true",
|
"traefik.enable=true",
|
||||||
"traefik.http.routers.pocketbase-phaseflow.entryPoints=websecure",
|
"traefik.http.routers.pocketbase-phaseflow.entryPoints=websecure",
|
||||||
"traefik.http.routers.pocketbase-phaseflow.middlewares=oidc-auth@file",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,6 +99,8 @@ job "phaseflow" {
|
|||||||
RESEND_API_KEY={{ with nomadVar "secrets/phaseflow" }}{{ .resend_api_key }}{{ end }}
|
RESEND_API_KEY={{ with nomadVar "secrets/phaseflow" }}{{ .resend_api_key }}{{ end }}
|
||||||
ENCRYPTION_KEY={{ with nomadVar "secrets/phaseflow" }}{{ .encryption_key }}{{ end }}
|
ENCRYPTION_KEY={{ with nomadVar "secrets/phaseflow" }}{{ .encryption_key }}{{ end }}
|
||||||
CRON_SECRET={{ with nomadVar "secrets/phaseflow" }}{{ .cron_secret }}{{ end }}
|
CRON_SECRET={{ with nomadVar "secrets/phaseflow" }}{{ .cron_secret }}{{ end }}
|
||||||
|
POCKETBASE_ADMIN_EMAIL={{ with nomadVar "secrets/phaseflow" }}{{ .pocketbase_admin_email }}{{ end }}
|
||||||
|
POCKETBASE_ADMIN_PASSWORD={{ with nomadVar "secrets/phaseflow" }}{{ .pocketbase_admin_password }}{{ end }}
|
||||||
EOH
|
EOH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user