version: '2.1'

services:
  db:
    image: mariadb
    restart: always
    container_name: "friendica-db"
    # I prefer to be picky about my networks - if you aren't as picky, you can probably omit the networking parts
    networks:
      - friendica-net
    command: "--table_definition_cache=-1"
    volumes:
    # Here should be a path to a directory for the container to store its data
    # You may prefer docker volumes for this
      - /persistent/friendica/mysql:/var/lib/mysql
    environment:
    # Customize these accordingly
      - MYSQL_USER=friendica
      - MYSQL_PASSWORD=password
      - MYSQL_DATABASE=friendica
      - MYSQL_ROOT_PASSWORD=password

  app:
    image: friendica:stable-apache
    restart: always
    container_name: "friendica"
    networks:
      - friendica-net
    ports:
      - "127.0.0.1:1090:80"
    volumes:
    # Similar to above, this is where the friendica installation data will be stored
      - /persistent/friendica/friendica:/var/www/html
    environment:
      - MYSQL_HOST=friendica-db
      - MYSQL_USER=friendica
      - MYSQL_PASSWORD=password
      - MYSQL_DATABASE=friendica
      - HOSTNAME=social.example.com
      - FRIENDICA_UPGRADE=false
    # You'll need to put in your particular mail settings
      - FRIENDICA_ADMIN_MAIL=
      - FRIENDICA_URL=
      - FRIENDICA_SITENAME=
      - SITENAME=
      - SMTP=
      - SMTP_PORT=
      - SMTP_DOMAIN=
      - SMTP_FROM=
    depends_on:
      - db

  # This container will run the scheduled PHP task. See "Activating scheduled tasks" at
  # https://friendi.ca/resources/installation/
  cron:
    image: friendica:stable-apache
    restart: always
    container_name: "friendica-cron"
    networks:
      - friendica-net
    entrypoint: "/bin/bash -c 'while true; do echo Initiated; php bin/worker.php; echo Complete; sleep 5m; done'"
    volumes:
    # Same volume as above
      - /persistent/friendica/friendica:/var/www/html
    environment:
    # Copy the same environment variables as the container above
      - MYSQL_HOST=friendica-db
      - MYSQL_USER=friendica
      - MYSQL_PASSWORD=password
      - MYSQL_DATABASE=friendica
      - HOSTNAME=social.example.com
      - FRIENDICA_UPGRADE=false
      - FRIENDICA_ADMIN_MAIL=
      - FRIENDICA_URL=
      - FRIENDICA_SITENAME=
      - SITENAME=
      - SMTP=
      - SMTP_PORT=
      - SMTP_DOMAIN=
      - SMTP_FROM=
    depends_on:
      - db

# As I said earlier, you can omit all this if you're not trying to restrict the container to specific IPs
networks:
  friendica-net:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.40.20.0/24
          ip_range: 172.40.20.0/24