1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
- hosts: monica
  tasks:

  - file:
      path: /usr/share/monica/{{ item }}
      state: directory
    loop:
      - app
      - db
      - php

  - copy:
      src: php.ini
      dest: /usr/share/monica/php/uploads.ini

  - copy:
      src: build
      dest: /usr/share/monica

  - docker_compose:
      project_name: monica
      build: yes
      pull: yes
      definition:
        version: "3.4"
        services:
          app:
            build: /usr/share/monica/build
            depends_on:
              - db
            ports:
              - 8080:80
            environment:
              - APP_ENV=production
              - APP_KEY={{ monica_app_key }}
              - DB_HOST=db
              - DB_USERNAME=monica
              - DB_PASSWORD={{ monica_db_password }}
              - MAIL_MAILER=smtp
              - MAIL_HOST={{ sendgrid_mail_host }}
              - MAIL_PORT={{ sendgrid_mail_port }}
              - MAIL_USERNAME={{ sendgrid_mail_username }}
              - MAIL_PASSWORD={{ sendgrid_mail_password }}
              - MAIL_ENCRYPTION={{ monica_mail_encryption }}
              - MAIL_FROM_ADDRESS={{ monica_mail_from_address }}
              - MAIL_FROM_NAME=Monica
              - APP_EMAIL_NEW_USERS_NOTIFICATION={{ monica_app_email_new_users_notification }}
              # - DEFAULT_FILESYSTEM=s3
              # - AWS_ENDPOINT={{ minio_host }}
              # - AWS_REGION=us-west-1
              # - AWS_BUCKET=monica
              # - AWS_ACCESS_KEY_ID={{ monica_aws_access_key }}
              # - AWS_SECRET_ACCESS_KEY={{ monica_aws_secret_key }}
            volumes:
              - /usr/share/monica/app:/var/www/html/storage
              - /usr/share/monica/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
            restart: always
          db:
            image: mysql:5.7
            environment:
              - MYSQL_RANDOM_ROOT_PASSWORD=true
              - MYSQL_DATABASE=monica
              - MYSQL_USER=monica
              - MYSQL_PASSWORD={{ monica_db_password }}
            volumes:
              - /usr/share/monica/db:/var/lib/mysql
            restart: always

  - template:
      src: monica.nginx
      dest: /etc/nginx/sites-available/monica.conf
    notify: Restart nginx
  - file:
      src: /etc/nginx/sites-available/monica.conf
      dest: /etc/nginx/sites-enabled/monica.conf
      state: link
    notify: Restart nginx

  handlers:

    - name: Restart nginx
      service:
        name: nginx
        state: restarted