services:
  partdb:
    container_name: partdb
    # By default Part-DB will be running under Port 8080, you can change it here
    ports:
      - '8087:80'
    restart: unless-stopped
    labels:
      - "compose2nix.settings.sops.secrets=songsheet/database/DATABASE_URL"
    image: jbtronics/part-db1:latest
    environment:
      # In docker env logs will be redirected to stderr
      - APP_ENV=docker

      # Diable the update checking because the GitHub Rate limit
      - CHECK_FOR_UPDATES=false

      # Uncomment this, if you want to use the automatic database migration feature. With this you have you do not have to
      # run the doctrine:migrations:migrate commands on installation or upgrade. A database backup is written to the uploads/
      # folder (under .automigration-backup), so you can restore it, if the migration fails.
      # This feature is currently experimental, so use it at your own risk!
      - DB_AUTOMIGRATE=true

      # You can configure Part-DB using environment variables
      # Below you can find the most essential ones predefined
      # However you can add any other environment configuration you want here
      # See .env file for all available options or https://docs.part-db.de/configuration.html
      # !!! Do not use quotes around the values, as they will be interpreted as part of the value and this will lead to errors !!!

      # The language to use serverwide as default (en, de, ru, etc.)
      - DEFAULT_LANG=en
      # The default timezone to use serverwide (e.g. Europe/Berlin)
      - DEFAULT_TIMEZONE=Europe/Copenhagen
      # The currency that is used inside the DB (and is assumed when no currency is set). This can not be changed later, so be sure to set it the currency used in your country
      - BASE_CURRENCY=DKK
      # The name of this installation. This will be shown as title in the browser and in the header of the website
      - INSTANCE_NAME=Part-DB

      # Allow users to download attachments to the server by providing an URL
      # This could be a potential security issue, as the user can retrieve any file the server has access to (via internet)
      - ALLOW_ATTACHMENT_DOWNLOADS=0
      # Use gravatars for user avatars, when user has no own avatar defined
      - USE_GRAVATAR=1

      # Override value if you want to show a given text on homepage.
      # When this is empty the content of config/banner.md is used as banner
      #- BANNER=This is a test banner<br>with a line break

      # If you use a reverse proxy in front of Part-DB, you must configure the trusted proxies IP addresses here (see reverse proxy documentation for more information):
      # - TRUSTED_PROXIES=127.0.0.0/8,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
      - TRUSTED_PROXIES=10.1.1.250

      # If you need to install additional composer packages (e.g., for specific mailer transports), you can specify them here:
      # The packages will be installed automatically when the container starts
      # - COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer symfony/sendgrid-mailer
    volumes:
      # By default
      # Devnote: # use named volumes instead of relative paths ./uploads, etc.
      - partdb_uploads_f:/var/www/html/uploads
      - partdb_media_f:/var/www/html/public/media
      - partdb_db_f:/var/www/html/var/db

  wavelog-db: # THIS IS NOW DANGLING BUT WILL BE THERE TO PREVENT BREAKAGE OF THE MAIN COMPOSE FILE
    image: mariadb:11.3
    container_name: wavelog-db
    environment:
      MARIADB_RANDOM_ROOT_PASSWORD: yes
      MARIADB_DATABASE: wavelog
      MARIADB_USER: wavelog
      MARIADB_PASSWORD: THIS_IS_NOT_IN_USE_yes # THIS DATABASE IS NOW MIGRATED PROPERLY
    volumes:
      - wavelog-dbdata:/var/lib/mysql
    restart: unless-stopped

  wavelog-main:
    container_name: wavelog-main
    image: ghcr.io/wavelog/wavelog:latest
    depends_on:
      - wavelog-db
    environment:
      CI_ENV: docker
    volumes:
      - wavelog-config:/var/www/html/application/config/docker
      - wavelog-uploads:/var/www/html/uploads
      - wavelog-userdata:/var/www/html/userdata
    ports:
      - "8086:80"
    restart: unless-stopped

  panel:
    image: ghcr.io/pelican-dev/panel:latest
    container_name: pelican_panel
    stdin_open: true
    tty: true
    restart: always
    networks:
      - pelican
    ports:
      - "8070:8080"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      # Mount the Caddyfile from the stable host path that pull.zsh deploys to
      - /etc/pelican/Caddyfile:/etc/caddy/Caddyfile:ro
      - pelican-data:/pelican-data
      - pelican-logs:/var/www/html/storage/logs
    environment:
      XDG_DATA_HOME: /pelican-data
      APP_URL: "https://pelican.prg-radio.org"
      LE_EMAIL: "kuutruu@posteo.net"
      TRUSTED_PROXIES: "10.1.1.250"
      BEHIND_PROXY: true

  wings:
    image: ghcr.io/pelican-dev/wings:latest
    container_name: pelican_wings
    restart: unless-stopped
    ports:
      - "8443:8443"
      - "2022:2022"
    stdin_open: true
    command: ["wings", "--ignore-certificate-errors"]
    tty: true
    environment:
      TZ: Europe/Copenhagen
      APP_TIMEZONE: Europe/Copenhagen
      WINGS_UID: 1000
      WINGS_GID: 1000
      WINGS_USERNAME: pelican
      BEHIND_PROXY: true # Just in case...
    volumes:
      - "/run/podman/podman.sock:/var/run/docker.sock"
      - "/var/lib/containers/storage/overlay-containers/:/var/lib/docker/containers/"
      - "/etc/pelican/:/etc/pelican/"
      - "/var/lib/pelican/:/var/lib/pelican/"
      - "/var/log/pelican/:/var/log/pelican/"
      - "/tmp/pelican/:/tmp/pelican/"
      - "/etc/ssl/certs:/etc/ssl/certs:ro"
    networks:
      - wings1

volumes:
  wavelog-dbdata:
  wavelog-uploads:
  wavelog-userdata:
  wavelog-config:
  partdb_uploads_f:
  partdb_media_f:
  partdb_db_f:
  pelican-data:
  pelican-logs:


networks:
  pelican:
    name: pelican
  wings1:
    name: wings1
    driver: bridge
    ipam:
      config:
        - subnet: 172.92.0.0/16
    driver_opts:
      com.docker.network.bridge.name: wings1