version: '2.1'

services:
  # --> By default, this file will launch a Password Pusher instance with an
  # ephemeral (temporary) database of SQLite3.  The database will be lost on
  # restart.  If you want a persistent database, enable one of databases below.
  #
  # Uncomment to add a PostgreSQL service
  #
  # postgres:
  #   image: docker.io/postgres:15
  #   volumes:
  #     - /var/lib/postgresql/data:/var/lib/postgresql/data
  #   ports:
  #     - "5432:5432"
  #   environment:
  #     POSTGRES_USER: pwpush_user
  #     POSTGRES_PASSWORD: pwpush_passwd
  #     POSTGRES_DB: pwpush_db

  # Uncomment to add a MySQL service
  #
  # mysql:
  #   image: mysql:8.0.32
  #   ports:
  #     - "3306:3306"
  #   environment:
  #     MYSQL_USER: 'pwpush_user'
  #     MYSQL_PASSWORD: 'pwpush_passwd'
  #     MYSQL_DATABASE: 'pwpush_db'
  #     MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
  #   volumes:
  #     - /var/lib/pwpush-mysql/data:/var/lib/mysql

  # Uncomment to add a MariaDB service
  #
  # mariadb:
  #   image: mariadb:10.6.5
  #   ports:
  #     - "3306:3306"
  #   environment:
  #     MARIADB_USER: 'pwpush_user'
  #     MARIADB_PASSWORD: 'pwpush_passwd'
  #     MARIADB_DATABASE: 'pwpush_db'
  #     MARIADB_RANDOM_ROOT_PASSWORD: 'yes'
  #   volumes:
  #     - /var/lib/pwpush-mariadb/data:/var/lib/mysql

  pwpush:
    image: docker.io/pglombardo/pwpush:latest
    ports:
      - "5100:5100"
    #
    # If using postgres, mysql or mariadb, uncomment the block and appropriate
    # lines below by removing "# " (two characters) from the beginning of
    # the line.  This is a YAML file: indentation & spacing are critical
    #
    # depends_on:
      # - postgres  # Uncomment to use PostgreSQL
      # - mysql     # Uncomment to use MySQL
      # - mariadb   # Uncomment to use MariaDB
    # links:
      # - postgres:postgres # Uncomment to use PostgreSQL
      # - mysql:mysql       # Uncomment to use MySQL
      # - mariadb:mariadb   # Uncomment to use MariaDB
    environment:
      # **--> !! If using postgres, mysql or mariadb, enable the appropriate line !! <--**
      #
      # --> Uncomment to use PostgreSQL
      # DATABASE_URL: 'postgres://pwpush_user:pwpush_passwd@postgres:5432/pwpush_db'
      #
      # --> Uncomment to use MySQL or MariaDB
      # DATABASE_URL: 'mysql2://pwpush_user:pwpush_passwd@mysql:3306/pwpush_db'
      #
      # --> Uncomment to use SQLite3 (ephemeral) db that will be lost on container restart
      DATABASE_URL: "sqlite3:db/db.sqlite3"
      #
      ################################################################################################
      # You can set other environment variables here, or in a env file.  See:
      # https://docs.docker.com/compose/environment-variables/
      #
      # Password Pusher provides an example Docker environment file:
      # https://github.com/pglombardo/PasswordPusher/tree/master/containers/docker/pwpush-docker-env-file

  ssl_proxy:
      image: caddy:latest
      ports:
        - "80:80"
        - "443:443"
      volumes:
        - ./Caddyfile:/etc/caddy/Caddyfile
        - caddy_data:/data
        - caddy_config:/config
      depends_on:
        - pwpush

volumes:
  caddy_data:
  caddy_config:

###############################################################################
# Other Notes
###############################################################################
# See also the Password Pusher Configuration documentation
# https://github.com/pglombardo/PasswordPusher/blob/master/Configuration.md
#
# Uncomment the following lines to set environment variables and add your own.
# environment:
#   PWP__PW__EXPIRE_AFTER_DAYS_DEFAULT: "1"
#   PWP__PW__EXPIRE_AFTER_VIEWS_MIN: "1"
#   PWP__PW__RETRIEVAL_STEP_DEFAULT: "true"
#
# Uncomment the following lines to mount a volume.
# volumes:
#   # Example of a persistent volume for the storage directory (file uploads)
#   - /path/to/directory:/opt/PasswordPusher/storage:rw
#
# Or you could override a single file in the container with a bind mount:
# volumes:
#   - type: bind
#     source: /path/to/my/custom/settings.yml
#     target: /opt/PasswordPusher/config/settings.yml
#
# To customise the application via configuration file, see settings.yml:
# https://github.com/pglombardo/PasswordPusher/blob/master/config/settings.yml
#
# Then you can use the above bind mount to overlay the file into the container on boot.