services:

  docksible_custom_app:
    image: "{{ app_image }}:{{ app_version }}"
    container_name: docksible_custom_app
    restart: always
    environment:
{% for item in extra_env_vars|dict2items %}
      "{{ item.key }}": "{{ item.value }}"
{% endfor %}

  docksible_db:
    image: mysql:8.3
    container_name: docksible_db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: "{{ database_root_password }}"
      MYSQL_USER: "{{ database_username }}"
      MYSQL_PASSWORD: "{{ database_password }}"
      MYSQL_DATABASE: "{{ database_name }}"
    volumes:
      - "$HOME/docksible-volumes/db_data:/var/lib/mysql"

  docksible_webserver:
    image: nginx:latest
    container_name: docksible_webserver
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "$HOME/docksible-volumes/nginx_data:/etc/nginx/conf.d"
      # TODO: This "WordPress volume" is needed for Certbot?
      - "$HOME/docksible-volumes/wordpress_data:/var/www/html"

{% if phpmyadmin %}
  docksible_phpmyadmin:
    depends_on:
      - docksible_db
    image: phpmyadmin
    container_name: docksible_phpmyadmin
    restart: unless-stopped
    environment:
      - "PMA_HOST=docksible_db"
{% endif %}

{% if ssh_proxy %}
  docksible_ssh_proxy:
    image: belalibrahim/simple-ssh-proxy:latest
    ports:
      - "2222:22"
    volumes:
      - "{{ ansible_env.HOME }}/docksible-volumes/ssh-proxy-data:/home/proxy_user/.ssh"
    container_name: docksible_ssh_proxy
{% endif %}
