top of page

How to Install Monica using Docker on Unraid

Updated: Feb 4

If you're into organizing your personal life digitally and have a knack for self-hosted solutions, you might have come across Monica. Monica is an open-source web application for personal relationship management. Think of it as a CRM, but for your personal life. Today, I'll guide you through the process of installing Monica using Docker on Unraid, including a detailed explanation of a Docker Compose YAML file.


Prerequisites

Before diving into the YAML file, let's cover the basics. To use Docker Compose on Unraid, you'll need to install a community application called "Docker Compose Manager" developed by "primeval_god". This is essential for running the Docker Compose YAML script. You can find more about it on the Unraid forum.


Understanding the Docker Compose YAML File

First of all , here is the docker-compose yaml file I produced based on the official one and I also looked at how Marius did it with the email settings :


version: "3.9"

services:
  app:
    image: monica
    depends_on:
      - db
    ports:
      - 8181:80
    environment:
      - APP_KEY= # Generate with `echo -n 'base64:'; openssl rand -base64 32`
      - DB_HOST=db
      - DB_USERNAME=monica
      - DB_PASSWORD=secret
      - APP_ENV=local
      - MAIL_MAILER=smtp
      - MAIL_HOST=smtp.gmail.com
      - MAIL_PORT=587
      - MAIL_USERNAME=Your-own-gmail-address
      - MAIL_PASSWORD=Your-own-app-password
      - MAIL_ENCRYPTION=tls
      - MAIL_FROM_ADDRESS=Your-own-gmail-address
      - MAIL_FROM_NAME=Monica
    volumes:
      - /mnt/user/appdata/monica:/var/www/html/storage
    restart: always

  db:
    image: mariadb:11
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=true
      - MYSQL_DATABASE=monica
      - MYSQL_USER=monica
      - MYSQL_PASSWORD=secret
    volumes:
      - /mnt/user/appdata/monica-db:/var/lib/mysql
    restart: always


Let's break down the Docker Compose YAML file I created, as it was a bit of a learning curve for me:


Version


version: "3.9"


This line specifies the version of the Docker Compose file format. I used the one from the official example.


Services

The services section defines the containers we will be running.


App Service


services:
  app:
    image: monica
    ...

  • image: monica: Specifies the Docker image to use, in this case, 'monica'.

  • depends_on: - db: Ensures the database (db) service is started before the app.

  • ports: - 8181:80: Maps port 80 in the container to port 8181 on the host machine (Unraid).

Environment Variables
  • APP_KEY: A key for your application encryption. Generate one of a lenghts of 32 characters

  • DB_HOST=db and other DB variables: These set up the database connection.

  • MAIL_*: Configuration for sending emails through the application.

Volumes
  • /mnt/user/appdata/monica:/var/www/html/storage: Maps a directory on your host to a directory in the container for persistent storage. By default on Unraid containers will store the data in /mnt/user/appdata/name_of_your_container

Restart Policy
  • restart: always: Ensures the container always restarts unless manually stopped.

Database Service


  db:
    image: mariadb:11
    ...

  • image: mariadb:11: Specifies the MariaDB image to use for the database.

  • environment: Similar to the app service, it's used for database configuration.

  • volumes: Ensures data persistence for the database.

Change Your Variables Values

Before you deploy Monica using the Docker Compose YAML file, it's crucial to customize certain values to fit your setup:


  1. APP_KEY: This is a unique encryption key for your instance.

  2. Database Credentials: DB_USERNAME, DB_PASSWORD, and their corresponding values in the db service should be set to your preferred database credentials.

  3. Mail Configuration: Adjust MAIL_* variables with your email settings. This includes your email provider details and credentials for sending out emails from Monica. Regarding the email I am using an application password for my gmail address.

  4. Volumes: The paths in the volumes section should be adjusted according to your Unraid file system and where you want to store Monica's data.

  5. Adjusting Ports: It’s vital to ensure that the port defined in the ports section of the app service (e.g., 8181:80) does not conflict with other services on your Unraid server. Change 8181 to any available port on your host.

Making these adjustments is key to a successful and tailored Monica installation on your Unraid server.



Installing Monica on Unraid


Install Docker Compose Manager on Unraid

You will find it in the community apps :


Navigate to "Docker" and then after the list of your existing container you will find this :


Create the stack using the YAML file

Click on "ADD NEW STACK" and choose the name of your stack, for example "Monica"


You should get a success message after hitting OK


Now let's edit the stack :


Edit stack


Choose "COMPOSE FILE"


Copy the content of your YAML file and replace everything here. Then hit "SAVE CHANGES"


Then you will receive this window :

Replace Icon by some icons URLs, for example I used thoses :

app Icon :

db Icon :


And just write down your Web UI URL for the app, so it will be something like :


Leave blank for shell.


And HIT OK . Once done, hit "COMPOSE UP" in order to run docker-compose and install everything :


It will open a window that will display the progress


And you are done !


CONGRATULATIONS ! Everything is running smoothly and you learned how to create your docker-compose yaml file and how to use it !


You can now access to Monica by going to http://your_unraid_IP:yourPort/ !





By following these steps, you should have a working instance of Monica on your Unraid server, customized to your preferences. It's a great example of the flexibility Docker offers, and a perfect project for diving into Docker Compose!


Enjoy 😎


AlexIn Tech


Update 04.02.2024 : Email reminders doesn't work ? How to solve this issue

I also had this issue and after a few days of searching a working solution I've finally came up with something working smoothly. In the following article you will find the solution :

7 views

Comments


bottom of page