# Shlink - URL shortener
# Port: 8080
# Self-hosted URL shortener

version: "3.9"
services:
  shlink-db:
    image: postgres
    container_name: Shlink-DB
    hostname: shlink-db
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "shlink", "-U", "shlinkuser"]
      interval: 10s
      timeout: 5s
      retries: 5
    user: 1000:1000
    volumes:
      - /home/homelab/docker/shlinkdb:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: shlink
      POSTGRES_USER: shlinkuser
      POSTGRES_PASSWORD: "REDACTED_PASSWORD"
    restart: unless-stopped

  shlink:
    image: shlinkio/shlink:stable
    container_name: Shlink
    hostname: shlink
    security_opt:
      - no-new-privileges:true
    ports:
      - 8335:8080
    environment:
      - TIMEZONE=America/Los_Angeles
      - INITIAL_API_KEY="REDACTED_API_KEY"
      - DB_DRIVER=postgres
      - DB_NAME=shlink
      - DB_USER=shlinkuser
      - DB_PASSWORD="REDACTED_PASSWORD"
      - DB_HOST=shlink-db
      - DB_PORT=5432
      - DEFAULT_DOMAIN=url.thevish.io
      - IS_HTTPS_ENABLED=true
      - GEOLITE_LICENSE_KEY="REDACTED_GEOLITE_KEY"
    restart: unless-stopped
    depends_on:
      shlink-db:
        condition: service_started

  shlink-web:
    image: shlinkio/shlink-web-client:stable
    container_name: Shlink-WEB
    hostname: shlink-web
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1
    ports:
      - 8336:80
    environment:
      - SHLINK_SERVER_NAME=thevish
      - SHLINK_SERVER_URL=https://url.thevish.io
      - SHLINK_SERVER_API_KEY="REDACTED_API_KEY"
    restart: unless-stopped
    depends_on:
      - shlink
