4. Running MyFin

4.1 Get the services up and running

Create a directory for Myfin to use, Myfin will write its configuration and data to this directory. (You need to have at least 5GB of disk space)

examples,

on Windows:

Create a folder on the C drive called "Myfin"

on Linux:

mkdir -p "/docker/myfin"

on MacOs:

Create a folder in the users "Documents" folder called "Myfin"

In the folder you created, create a file called: docker-compose.yml

Copy and pasted the following into that file:

services:
  myfin:
    image: <image version>
    container_name: myfin
    restart: always
    expose:
      - "${INTERNAL_PORT}"
    depends_on:
      db:
        condition: service_healthy
    env_file:
      - .env
    networks:
      - frontend
      - backend
  db:
    container_name: myfin_db
    image: mysql:8.0
    restart: always
    command: --default-authentication-plugin=mysql_native_password --skip-ssl
    environment:
      MYSQL_DATABASE: ${DATABASE_NAME}
      MYSQL_USER: ${DATABASE_USER}
      MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD}
      MYSQL_ROOT_HOST: "%"
    volumes:
      - ./db_data:/var/lib/mysql
    networks:
      - backend
    healthcheck:
      test:
        [
          "CMD",
          "mysqladmin",
          "ping",
          "-h",
          "localhost",
          "-u",
          "root",
          "-p${DATABASE_ROOT_PASSWORD}",
        ]
      interval: 5s
      timeout: 5s
      retries: 20
      start_period: 30s
  npm:
    image: jc21/nginx-proxy-manager:latest
    container_name: nginx_proxy_manager
    restart: always
    ports:
      - "80:80"
      - "81:81"
      - "443:443"
    volumes:
      - ./npm/data:/data
      - ./npm/letsencrypt:/etc/letsencrypt
    depends_on:
      - myfin
    networks:
      - frontend
  cloudflared:
    image: cloudflare/cloudflared:latest
    container_name: cloudflared
    restart: always
    command: tunnel run
    environment:
      - TUNNEL_TOKEN=${CLOUDFLARE_TUNNEL_TOKEN}
    depends_on:
      - npm
    networks:
      - frontend

networks:
  frontend:
    driver: bridge

  backend:
    driver: bridge
    internal: true

make sure to change <image version> with the correct software version. If you are using a subscription license use the following image:

image: get.myfin-hub.com/myfin/subscription:latest

of you are using a perpetual license use the version your license if for, for example:

image: get.myfin-hub.com/myfin/V0:latest
or
image: get.myfin-hub.com/myfin/V1:latest
etc

Save and close the file

In this docker-compose file, we have the MyFin service, the SQL service and then an Nginx Proxy manager service.

In the same folder, create a file called .env

Copy and pasted in the following into that file:

# The internal and external ports to use
INTERNAL_PORT=3000

# name of domain you access MyFin from, eg http://localhost:3000, https://myfin-pc.local, http://192.168.0.250 etc
DOMAIN_URL=<Your domain or IP address>
# Set to 0 if you are using a trusted certificate for SSL (https), set to 1 if using self signed
ALLOW_SELF_SIGNED_CERTS=1

# db host will be the name of the postgres container in the compose file
DATABASE_HOST=db
DATABASE_PORT=3306
DATABASE_USER=myfin_user
DATABASE_PASSWORD=<a long user password>
DATABASE_NAME=myfin
DATABASE_ROOT_PASSWORD=<a long root user password>

# Used to encrypt your SMTP password
SMTP_ENCRYPTION_KEY=<A 64 char random sting of numbers and chars>
# To enable or disable email sending
EMAIL_SEND_MAIL=<true or false>
# SMTP for User invites, password resets etc etc
EMAIL_SENDER_HOST=
EMAIL_SENDER_PORT=
EMAIL_SENDER_USER=
EMAIL_SENDER_PASS=<App Password if using gmail>

# Passkey url, You instance domain name without http / https, eg your-server.com, localhost, 192.168.0.250
AUTH_RRP_ID=
# Log in session length
AUTH_SESSION_HOURS=9

CLOUDFLARE_TUNNEL_TOKEN=

Fill in your desired and required details. So set the passwords, fill in your SMTP details and your domain details.

Remember to add your Cloudflare Tunnel token from the previous “Create a Cloudflare Tunnel” step:

CLOUDFLARE_TUNNEL_TOKEN=eyJhIjoiZmY5...

Save and close the file

Everything is ready to start the Myfin service.

In the same folder open up your terminal and run the following command

docker compose up -d

This process may take several minutes, so give it a bit of time to get started.