This guide deploys Monica with Docker Compose and PostgreSQL.
It supports Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible systems.
- name: Install Monica
hosts: monica
become: true
vars:
monica_root: /opt/monica
monica_port: 8087
tasks:
- name: Install Docker on Debian/Ubuntu
apt:
name:
- docker.io
- docker-compose-plugin
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker on RHEL family
dnf:
name:
- docker
- docker-compose-plugin
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker
service:
name: docker
state: started
enabled: true
- name: Create Monica directory
file:
path: "{{ monica_root }}"
state: directory
mode: "0755"
- name: Write Monica compose file
copy:
dest: "{{ monica_root }}/docker-compose.yml"
mode: "0644"
content: |
services:
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: monica
POSTGRES_USER: monica
POSTGRES_PASSWORD: change_me_now
volumes:
- ./db:/var/lib/postgresql/data
app:
image: monica:latest
restart: unless-stopped
depends_on:
- db
ports:
- "{{ monica_port }}:80"
environment:
DB_CONNECTION: pgsql
DB_HOST: db
DB_PORT: 5432
DB_DATABASE: monica
DB_USERNAME: monica
DB_PASSWORD: change_me_now
volumes:
- ./data:/var/www/html/storage
- name: Start Monica stack
command: docker compose up -d
args:
chdir: "{{ monica_root }}"
Any questions?
Feel free to contact us. Find all contact information on our contact page.