|
| 1 | +services: |
| 2 | +# Make sure you have updated/checked the .env file with the correct variables. |
| 3 | +# All the ${ xx } need to be defined there. |
| 4 | + # Tailscale Sidecar Configuration |
| 5 | + tailscale: |
| 6 | + image: tailscale/tailscale:latest # Image to be used |
| 7 | + container_name: tailscale-${SERVICE} # Name for local container management |
| 8 | + hostname: ${SERVICE} # Name used within your Tailscale environment |
| 9 | + environment: |
| 10 | + - TS_AUTHKEY=${TS_AUTHKEY} |
| 11 | + - TS_STATE_DIR=/var/lib/tailscale |
| 12 | + - TS_SERVE_CONFIG=/config/serve.json # Tailscale Serve configuration to expose the web interface on your local Tailnet - remove this line if not required |
| 13 | + - TS_USERSPACE=false |
| 14 | + - TS_ENABLE_HEALTH_CHECK=true # Enable healthcheck endpoint: "/healthz" |
| 15 | + - TS_LOCAL_ADDR_PORT=127.0.0.1:41234 # The <addr>:<port> for the healthz endpoint |
| 16 | + #- TS_ACCEPT_DNS=true # Uncomment when using MagicDNS |
| 17 | + volumes: |
| 18 | + - ./config:/config # Config folder used to store Tailscale files - you may need to change the path |
| 19 | + - ./ts/state:/var/lib/tailscale # Tailscale requirement - you may need to change the path |
| 20 | + devices: |
| 21 | + - /dev/net/tun:/dev/net/tun # Network configuration for Tailscale to work |
| 22 | + cap_add: |
| 23 | + - net_admin # Tailscale requirement |
| 24 | + #ports: |
| 25 | + # - 0.0.0.0:${SERVICEPORT}:${SERVICEPORT} # Binding port ${SERVICE}PORT to the local network - may be removed if only exposure to your Tailnet is required |
| 26 | + # If any DNS issues arise, use your preferred DNS provider by uncommenting the config below |
| 27 | + #dns: |
| 28 | + # - ${DNS_SERVER} |
| 29 | + healthcheck: |
| 30 | + test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:41234/healthz"] # Check Tailscale has a Tailnet IP and is operational |
| 31 | + interval: 1m # How often to perform the check |
| 32 | + timeout: 10s # Time to wait for the check to succeed |
| 33 | + retries: 3 # Number of retries before marking as unhealthy |
| 34 | + start_period: 10s # Time to wait before starting health checks |
| 35 | + restart: always |
| 36 | + |
| 37 | + # ${SERVICE} |
| 38 | + application: |
| 39 | + image: ${IMAGE_URL} # Image to be used |
| 40 | + network_mode: service:tailscale # Sidecar configuration to route ${SERVICE} through Tailscale |
| 41 | + container_name: app-${SERVICE} # Name for local container management |
| 42 | + environment: |
| 43 | + - PUID=1000 |
| 44 | + - PGID=1000 |
| 45 | + - TZ=${TZ} |
| 46 | + - TANDOOR_PORT=${SERVICEPORT} |
| 47 | + volumes: |
| 48 | + - ./${SERVICE}-data/staticfiles:/opt/recipes/statisfiles |
| 49 | + - ./${SERVICE}-data/mediafiles:/opt/recipes/mediafiles |
| 50 | + env_file: |
| 51 | + - ./.env |
| 52 | + depends_on: |
| 53 | + tailscale: |
| 54 | + condition: service_healthy |
| 55 | + database: |
| 56 | + condition: service_healthy |
| 57 | + healthcheck: |
| 58 | + test: ["CMD", "pgrep", "-f", "${SERVICE}"] # Check if ${SERVICE} process is running |
| 59 | + interval: 1m # How often to perform the check |
| 60 | + timeout: 10s # Time to wait for the check to succeed |
| 61 | + retries: 3 # Number of retries before marking as unhealthy |
| 62 | + start_period: 30s # Time to wait before starting health checks |
| 63 | + restart: always |
| 64 | + |
| 65 | + database: |
| 66 | + image: postgres:16-alpine |
| 67 | + network_mode: service:tailscale |
| 68 | + container_name: app-${SERVICE}-database |
| 69 | + environment: |
| 70 | + POSTGRES_PASSWORD: ${DB_PASSWORD} |
| 71 | + POSTGRES_USER: ${DB_USERNAME} |
| 72 | + POSTGRES_DB: ${DB_DATABASE_NAME} |
| 73 | + volumes: |
| 74 | + - ./${SERVICE}-data/database:/var/lib/postgresql/data |
| 75 | + healthcheck: |
| 76 | + test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE_NAME}"] # Check if postgres is ready |
| 77 | + interval: 1m # How often to perform the check |
| 78 | + timeout: 10s # Time to wait for the check to succeed |
| 79 | + retries: 3 # Number of retries before marking as unhealthy |
| 80 | + start_period: 30s # Time to wait before starting health checks |
| 81 | + restart: always |
0 commit comments