---

- name: fider network
  docker_network:
    name: fider

- name: fider database volume
  docker_volume:
    name: fider_db

- name: fider database container
  docker_container:
    name: fider_db
    image: postgres:10
    state: started
    restart_policy: always
    networks:
      - name: fider
    volumes:
      - fider_db:/var/lib/postgresql/data
    env:
      POSTGRES_USER: "fider"
      POSTGRES_PASSWORD: "{{ postgres_passwords.fider }}"

- name: fider app container
  docker_container:
    name: fider
    image: getfider/fider:stable
    restart_policy: always
    networks:
      - name: fider
      - name: external_services
      - name: postfix
    env:
      GO_ENV: "production"
      DATABASE_URL: "postgres://fider:{{ postgres_passwords.fider }}@fider_db:5432/fider?sslmode=disable"
      JWT_SECRET: "{{ fider_jwt_secret }}"

      EMAIL_NOREPLY: noreply@{{ fider.domain }}
      EMAIL_SMTP_HOST: "{{ smtp_host }}"
      EMAIL_SMTP_PORT: "{{ smtp_port }}"
      EMAIL_SMTP_USERNAME: "noop"
      EMAIL_SMTP_PASSWORD: "noop"

      VIRTUAL_HOST: "{{ fider.domain }}"
      LETSENCRYPT_HOST: "{{ fider.domain }}"
      LETSENCRYPT_EMAIL: "{{ letsencrypt_email}}"