espocrm

Installing EspoCrm with Docker

This post is about installing EspoCrm in a Docker environment. I found the documentation and public docker examples to be quite limited, so here is the setup we use at my company.

Choosing EspoCrm

Our company SugarCrm system handled the job for a great many years, but is no longer supported, had a basic feature set, and some things were never really usable (e.g. email). In looking at alternatives, here are some of the reasons we chose Espocrm.

Free, open source.
Docker image.
User definable roles and privileges.
Custom fields.
Formulas – to auto-generate field values. e.g. to calculate the sum total of a customer ordered items.
Custom entities.
Email that actually works. Sugar was garbage.
Good user interface, intuitive and fast.
Extensions and plugins available.
Api

We test drove the online demo version to check out the features and overall usability.
It’s been in use at the company for 6 months now, and there are no regrets. There was a learning curve on the more advanced features, and some difficulties with limited to no examples to follow in some cases. I’ll try to provide some examples in future posts.

Set up the database

Log into the mysql command line.
Create the database:

CREATE DATABASE espocrm_db CHARACTER SET utf8;

Create the database user and set privileges:

CREATE USER 'espocrm_user' IDENTIFIED BY 'YourDbUserPasswordHere';
GRANT ALL PRIVILEGES ON espocrm_db.* TO 'espocrm_user';
FLUSH PRIVILEGES;

Port Forwarding

Forward the port you plan to use. I chose 8080.

Docker Compose

Create the espocrm folder for persistent data:

sudo mkdir /dockerdata/espocrm

Create the docker-compose file:

# espocrm
espocrm:
  image: espocrm/espocrm
  container_name: espocrm
  # Environment variables
  environment:
    # [MariaDb compose service Name]:[Port] 
    ESPOCRM_DATABASE_HOST: db:3306
    ESPOCRM_DATABASE_NAME: espocrm_db
    ESPOCRM_DATABASE_USER: espocrm_user
    ESPOCRM_DATABASE_PASSWORD: YourDbUserPasswordHere 
    ESPOCRM_ADMIN_USERNAME: admin
    ESPOCRM_ADMIN_PASSWORD: YourCrmAdminPasswordHere  # You can change this later, when you log in
    ESPOCRM_SITE_URL: "http://localhost:8080"
  restart: always
  depends_on:
    - db
  ports:
    # [Port exposed] : [Port running inside container]
    - 8080:80
  volumes:
    # [physical path]:[path within the container]
    # Choose a local dir for persisted data so it can be backed up.
    - /dockerdata/espocrm:/var/www/html

Note that the database container has a host name of ‘db’. Excerpt:

  db:
    image: mariadb
    container_name: db
    hostname: db
    ports:
      - '3306:3306'
    ...

We also need to create the daemon service.

  # espocrm-daemon - php daemon for sending notifications, mass mailing, syncing, cleanup, etc.
  # Same image, different entry point.
  espocrm-daemon:
    image: espocrm/espocrm
    volumes:
      - /dockerdata/espocrm:/var/www/html
    restart: always
    entrypoint: docker-daemon.sh

Start the Containers

sudo docker-compose  up  --detach  espocrm
sudo docker-compose  up  --detach  espocrm-daemon

View the log to check that everything is running:

docker-compose logs --timestamps --tail 100  espocrm

Log into EspoCrm

http://YourIPAddressHere:8080

Now you’re ready to configure your system.