Add misc CICD scripts and compose file
This commit is contained in:
parent
5e2b41da5d
commit
fd4d823cf5
22
cicd/add-dns.sh
Executable file
22
cicd/add-dns.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ZONE_ID=$1
|
||||||
|
RECORD_NAME=$2
|
||||||
|
RECORD_COMMENT=$3
|
||||||
|
API_TOKEN=$4
|
||||||
|
TUNNEL_ID=$5
|
||||||
|
|
||||||
|
curl --request POST --silent \
|
||||||
|
--url https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--header "Authorization: Bearer $API_TOKEN" \
|
||||||
|
--data '{
|
||||||
|
"content": "'$TUNNEL_ID'.cfargotunnel.com",
|
||||||
|
"name": "'$RECORD_NAME'",
|
||||||
|
"comment": "'$RECORD_COMMENT'",
|
||||||
|
"proxied": true,
|
||||||
|
"type": "CNAME",
|
||||||
|
"ttl": 1
|
||||||
|
}' \
|
19
cicd/create-tunnel-config.sh
Executable file
19
cicd/create-tunnel-config.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TUNNEL_ID=$1
|
||||||
|
HOSTNAME=$2
|
||||||
|
SERVICE=$3
|
||||||
|
|
||||||
|
echo "Creating tunnel config for $HOSTNAME"
|
||||||
|
|
||||||
|
cat <<EOF > cloudflared-tunnel-config.yml
|
||||||
|
tunnel: $TUNNEL_ID
|
||||||
|
credentials-file: /etc/cloudflared/auth.json
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
- hostname: $HOSTNAME
|
||||||
|
service: $SERVICE
|
||||||
|
- service: http_status:404
|
||||||
|
EOF
|
55
cicd/docker-compose-cicd.yml
Normal file
55
cicd/docker-compose-cicd.yml
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
cloudflare:
|
||||||
|
image: cloudflare/cloudflared:latest
|
||||||
|
command: tunnel run
|
||||||
|
volumes:
|
||||||
|
- cloudflared-config:/etc/cloudflared:ro
|
||||||
|
|
||||||
|
libretunes:
|
||||||
|
image: registry.mregirouard.com/libretunes/libretunes:${LIBRETUNES_VERSION}
|
||||||
|
environment:
|
||||||
|
REDIS_URL: redis://redis:6379
|
||||||
|
POSTGRES_HOST: postgres
|
||||||
|
POSTGRES_USER: libretunes
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
POSTGRES_DB: libretunes
|
||||||
|
volumes:
|
||||||
|
- libretunes-audio:/site/audio
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
- postgres
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:latest
|
||||||
|
volumes:
|
||||||
|
- libretunes-redis:/data
|
||||||
|
restart: always
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "redis-cli", "ping"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:latest
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: libretunes
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
POSTGRES_DB: libretunes
|
||||||
|
volumes:
|
||||||
|
- libretunes-postgres:/var/lib/postgresql/data
|
||||||
|
restart: always
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U libretunes"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
cloudflared-config:
|
||||||
|
libretunes-audio:
|
||||||
|
libretunes-redis:
|
||||||
|
libretunes-postgres:
|
22
cicd/remove-dns.sh
Executable file
22
cicd/remove-dns.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ZONE_ID=$1
|
||||||
|
RECORD_NAME=$2
|
||||||
|
RECORD_COMMENT=$3
|
||||||
|
API_TOKEN=$4
|
||||||
|
|
||||||
|
RECORD_ID=$(
|
||||||
|
curl --request GET --silent \
|
||||||
|
--url "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?name=$RECORD_NAME&comment=$RECORD_COMMENT" \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
--header "Authorization: Bearer $API_TOKEN" \
|
||||||
|
| jq -r '.result[0].id')
|
||||||
|
|
||||||
|
echo "Deleting DNS record ID $RECORD_ID"
|
||||||
|
|
||||||
|
curl --request DELETE --silent \
|
||||||
|
--url "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID" \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
--header "Authorization: Bearer $API_TOKEN"
|
Loading…
x
Reference in New Issue
Block a user