WIP: add cron job to download extra dns json file #5
@ -25,3 +25,6 @@ ENABLE_DERP=false
|
||||
# See https://git.coopcloud.tech/coop-cloud/backup-bot-two
|
||||
ENABLE_BACKUPS=true
|
||||
|
||||
## allow cron updater
|
||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.dns.yml"
|
||||
#DNS_REPO=owner/repo
|
||||
4
abra.sh
4
abra.sh
@ -1,3 +1,5 @@
|
||||
# Set any config versions here
|
||||
# Docs: https://docs.coopcloud.tech/maintainers/handbook/#manage-configs
|
||||
export CONFIG_YAML_VERSION=v4
|
||||
export CONFIG_YAML_VERSION=v5
|
||||
export EXTRA_RECORDS_VERSION=v1
|
||||
export DNS_DOWNLOADER_VERSION=v1
|
||||
|
||||
24
compose.dns.yml
Normal file
24
compose.dns.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
services:
|
||||
cron:
|
||||
image: alpine:3.23.3
|
||||
volumes:
|
||||
- data:/data
|
||||
configs:
|
||||
- source: extra_dns_downloader
|
||||
target: /entrypoint.sh
|
||||
entrypoint: ["/entrypoint.sh"]
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 0
|
||||
labels:
|
||||
- "swarm.cronjob.enable=true"
|
||||
|
|
||||
- "swarm.cronjob.schedule=0 * * * *"
|
||||
restart_policy:
|
||||
condition: none
|
||||
|
||||
configs:
|
||||
extra_dns_downloader:
|
||||
name: ${STACK_NAME}_dns_downloader_${DNS_DOWNLOADER_VERSION}
|
||||
file: extra-downloader.sh
|
||||
template_driver: golang
|
||||
@ -11,6 +11,8 @@ services:
|
||||
configs:
|
||||
- source: config_yaml
|
||||
target: /etc/headscale/config.yaml
|
||||
- source: extra_dns_records
|
||||
target: /var/lib/headscale/extra-records.json
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
@ -43,6 +45,7 @@ services:
|
||||
networks:
|
||||
- proxy
|
||||
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
@ -55,3 +58,7 @@ configs:
|
||||
name: ${STACK_NAME}_config_yaml_${CONFIG_YAML_VERSION}
|
||||
file: config.yaml.tmpl
|
||||
template_driver: golang
|
||||
extra_dns_records:
|
||||
name: ${STACK_NAME}_extra_records_${EXTRA_RECORDS_VERSION}
|
||||
file: extra-records.json
|
||||
|
||||
|
||||
@ -308,7 +308,7 @@ dns:
|
||||
# Extra DNS records
|
||||
# so far only A and AAAA records are supported (on the tailscale side)
|
||||
# See: docs/ref/dns.md
|
||||
extra_records: []
|
||||
# extra_records: []
|
||||
# - name: "grafana.myvpn.example.com"
|
||||
# type: "A"
|
||||
# value: "100.64.0.3"
|
||||
@ -318,7 +318,7 @@ dns:
|
||||
#
|
||||
# Alternatively, extra DNS records can be loaded from a JSON file.
|
||||
# Headscale processes this file on each change.
|
||||
# extra_records_path: /var/lib/headscale/extra-records.json
|
||||
extra_records_path: /var/lib/headscale/extra-records.json
|
||||
|
3wordchant
commented
Will this cause any problems for deployments not using Will this cause any problems for deployments not using `compose.dns.yml`? I wonder about putting this inside an `{{ if `?
|
||||
|
||||
# Unix socket used for the CLI to connect without authentication
|
||||
# Note: for production you will want to set this to something like:
|
||||
|
||||
6
extra-downloader.sh
Executable file
6
extra-downloader.sh
Executable file
@ -0,0 +1,6 @@
|
||||
apk add --no-cache --quiet wget
|
||||
|
3wordchant
commented
Could also inline this whole file as the Could also inline this whole file as the `entrypoint`, given it's so short? No big deal either way though.
|
||||
apk add --no-cache --quiet curl
|
||||
apk add --no-cache --quiet jq
|
||||
|
||||
version=$(curl https://git.coopcloud.tech/api/v1/repos/{{ env "DNS_REPO" }}/tags | jq -r '.[0].name')
|
||||
wget https://git.coopcloud.tech/{{ env "DNS_REPO" }}/raw/tag/$version/headscale-records.json -O /data/extra-records.json
|
||||
1
extra-records.json
Normal file
1
extra-records.json
Normal file
@ -0,0 +1 @@
|
||||
[]
|
||||
|
3wordchant
commented
Could cheekily inline this into Could cheekily inline this into `compose.dns.yml` maybe? https://stackoverflow.com/a/77561067/14269772
|
||||
Reference in New Issue
Block a user
Love it! For a million bonus points, it might be nice to add a fallback built-in cron option for folks who don't have / don't want a
swarm-cronjobapp? Highly optional though IMO.