Skip to content

Latest commit

 

History

History
742 lines (501 loc) · 26.7 KB

README.md

File metadata and controls

742 lines (501 loc) · 26.7 KB

License: AGPL v3 Codacy Badge Build Status Docker Automated buid Docker Pulls Docker Version Docker Size GitHub stars

Dolibarr on Docker

Docker image for Dolibarr.

Provides full database configuration, production mode, HTTPS enforcer (SSL must be provided by reverse proxy), handles upgrades, and so on...

What is Dolibarr

Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda, ...).

More informations

Supported tags and respective Dockerfile links

Dockerhub monogramm/docker-dolibarr/

Tags:

  • 16.0.1-apache 16.0-apache apache 16.0.1 16.0 latest (images/16.0/php7.3-apache-amd64/Dockerfile)
  • 16.0.1-apache 16.0-apache apache 16.0.1 16.0 latest (images/16.0/php7.3-apache-i386/Dockerfile)
  • 16.0.1-fpm 16.0-fpm fpm (images/16.0/php7.3-fpm-amd64/Dockerfile)
  • 16.0.1-fpm 16.0-fpm fpm (images/16.0/php7.3-fpm-i386/Dockerfile)
  • 16.0.1-fpm-alpine 16.0-fpm-alpine fpm-alpine (images/16.0/php7.3-fpm-alpine-amd64/Dockerfile)
  • 16.0.1-fpm-alpine 16.0-fpm-alpine fpm-alpine (images/16.0/php7.3-fpm-alpine-i386/Dockerfile)
  • 15.0.3-apache 15.0-apache 15.0.3 15.0 (images/15.0/php7.3-apache-amd64/Dockerfile)
  • 15.0.3-apache 15.0-apache 15.0.3 15.0 (images/15.0/php7.3-apache-i386/Dockerfile)
  • 15.0.3-fpm 15.0-fpm (images/15.0/php7.3-fpm-amd64/Dockerfile)
  • 15.0.3-fpm 15.0-fpm (images/15.0/php7.3-fpm-i386/Dockerfile)
  • 15.0.3-fpm-alpine 15.0-fpm-alpine (images/15.0/php7.3-fpm-alpine-amd64/Dockerfile)
  • 15.0.3-fpm-alpine 15.0-fpm-alpine (images/15.0/php7.3-fpm-alpine-i386/Dockerfile)
  • 14.0.5-apache 14.0-apache 14.0.5 14.0 (images/14.0/php7.3-apache-amd64/Dockerfile)
  • 14.0.5-apache 14.0-apache 14.0.5 14.0 (images/14.0/php7.3-apache-i386/Dockerfile)
  • 14.0.5-fpm 14.0-fpm (images/14.0/php7.3-fpm-amd64/Dockerfile)
  • 14.0.5-fpm 14.0-fpm (images/14.0/php7.3-fpm-i386/Dockerfile)
  • 14.0.5-fpm-alpine 14.0-fpm-alpine (images/14.0/php7.3-fpm-alpine-amd64/Dockerfile)
  • 14.0.5-fpm-alpine 14.0-fpm-alpine (images/14.0/php7.3-fpm-alpine-i386/Dockerfile)
  • 13.0.5-apache 13.0-apache 13.0.5 13.0 (images/13.0/php7.3-apache-amd64/Dockerfile)
  • 13.0.5-apache 13.0-apache 13.0.5 13.0 (images/13.0/php7.3-apache-i386/Dockerfile)
  • 13.0.5-fpm 13.0-fpm (images/13.0/php7.3-fpm-amd64/Dockerfile)
  • 13.0.5-fpm 13.0-fpm (images/13.0/php7.3-fpm-i386/Dockerfile)
  • 13.0.5-fpm-alpine 13.0-fpm-alpine (images/13.0/php7.3-fpm-alpine-amd64/Dockerfile)
  • 13.0.5-fpm-alpine 13.0-fpm-alpine (images/13.0/php7.3-fpm-alpine-i386/Dockerfile)
  • 12.0.5-apache 12.0-apache 12.0.5 12.0 (images/12.0/php7.3-apache-amd64/Dockerfile)
  • 12.0.5-apache 12.0-apache 12.0.5 12.0 (images/12.0/php7.3-apache-i386/Dockerfile)
  • 12.0.5-fpm 12.0-fpm (images/12.0/php7.3-fpm-amd64/Dockerfile)
  • 12.0.5-fpm 12.0-fpm (images/12.0/php7.3-fpm-i386/Dockerfile)
  • 12.0.5-fpm-alpine 12.0-fpm-alpine (images/12.0/php7.3-fpm-alpine-amd64/Dockerfile)
  • 12.0.5-fpm-alpine 12.0-fpm-alpine (images/12.0/php7.3-fpm-alpine-i386/Dockerfile)
  • 11.0.5-apache 11.0-apache 11.0.5 11.0 (images/11.0/php7.3-apache-amd64/Dockerfile)
  • 11.0.5-apache 11.0-apache 11.0.5 11.0 (images/11.0/php7.3-apache-i386/Dockerfile)
  • 11.0.5-fpm 11.0-fpm (images/11.0/php7.3-fpm-amd64/Dockerfile)
  • 11.0.5-fpm 11.0-fpm (images/11.0/php7.3-fpm-i386/Dockerfile)
  • 11.0.5-fpm-alpine 11.0-fpm-alpine (images/11.0/php7.3-fpm-alpine-amd64/Dockerfile)
  • 11.0.5-fpm-alpine 11.0-fpm-alpine (images/11.0/php7.3-fpm-alpine-i386/Dockerfile)
  • develop-apache develop-apache develop develop (images/develop/php7.3-apache-amd64/Dockerfile)
  • develop-apache develop-apache develop develop (images/develop/php7.3-apache-i386/Dockerfile)
  • develop-fpm develop-fpm (images/develop/php7.3-fpm-amd64/Dockerfile)
  • develop-fpm develop-fpm (images/develop/php7.3-fpm-i386/Dockerfile)
  • develop-fpm-alpine develop-fpm-alpine (images/develop/php7.3-fpm-alpine-amd64/Dockerfile)
  • develop-fpm-alpine develop-fpm-alpine (images/develop/php7.3-fpm-alpine-i386/Dockerfile)

How to run this image

This image is based on the officiel PHP repository. It is inspired from nextcloud and tuxgasy/docker-dolibarr.

This image does not contain the database for Dolibarr. You need to use either an existing database or a database container.

This image is designed to be used in a micro-service environment. There are two versions of the image you can choose from.

The apache tag contains a full Dolibarr installation including an apache web server. It is designed to be easy to use and gets you running pretty fast. This is also the default for the latest tag and version tags that are not further specified.

The second option is a fpm container. It is based on the php-fpm image and runs a fastCGI-Process that serves your Dolibarr page. To use this image it must be combined with any webserver that can proxy the http requests to the FastCGI-port of the container.

Using the apache image

The apache image contains a webserver and exposes port 80. To start the container type:

$ docker run -d -e DOLI_AUTO_CONFIGURE='' -p 8080:80 monogramm/docker-dolibarr

Now you can access Dolibarr at http://localhost:8080/ from your host system.

Using the fpm image

To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container. For fpm connection this container exposes port 9000. In most cases you might want use another container or your host as proxy. If you use your host you can address your Dolibarr container directly on port 9000. If you use another container, make sure that you add them to the same docker network (via docker run --network <NAME> ... or a docker-compose file). In both cases you don't want to map the fpm port to you host.

$ docker run -d -e DOLI_AUTO_CONFIGURE='' monogramm/docker-dolibarr:fpm

As the fastCGI-Process is not capable of serving static files (style sheets, images, ...) the webserver needs access to these files. This can be achieved with the volumes-from option. You can find more information in the docker-compose section.

Using an external database

By default this container does not contain the database for Dolibarr. You need to use either an existing database or a database container.

The Dolibarr setup wizard (should appear on first run) allows connecting to an existing MySQL/MariaDB or PostgreSQL database. You can also link a database container, e. g. --link my-mysql:mysql, and then use mysql as the database host on setup. More info is in the docker-compose section.

Persistent data

The Dolibarr installation and all data beyond what lives in the database (file uploads, etc) are stored in the unnamed docker volume volume /var/www/html and /var/www/documents. The docker daemon will store that data within the docker directory /var/lib/docker/volumes/.... That means your data is saved even if the container crashes, is stopped or deleted.

To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder. To achieve this you need one volume for your database container and Dolibarr.

Dolibarr:

  • /var/www/html/ folder where all Dolibarr data lives
  • /var/www/documents/ folder where all Dolibarr documents lives
$ docker run -d \
    -v dolibarr_html:/var/www/html \
    -v dolibarr_docs:/var/www/documents \
    -e DOLI_AUTO_CONFIGURE='' \
    monogramm/docker-dolibarr

Database:

  • /var/lib/mysql MySQL / MariaDB Data
  • /var/lib/postgresql/data PostgreSQL Data
$ docker run -d \
    -v db:/var/lib/mysql \
    mariadb \
    --character_set_client=utf8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --character-set-client-handshake=FALSE

If you want to get fine grained access to your individual files, you can mount additional volumes for config, your theme and custom modules. The conf is stored in subfolder inside /var/www/html/. The modules are split into core apps (which are shipped with Dolibarr and you don't need to take care of) and a custom folder. If you use a custom theme it would go into the theme subfolder.

Overview of the folders that can be mounted as volumes:

  • /var/www/html Main folder, needed for updating
  • /var/www/html/custom installed / modified modules
  • /var/www/html/conf local configuration
  • /var/www/html/theme/<YOUR_CUSTOM_THEME> theming/branding

If you want to use named volumes for all of these it would look like this

$ docker run -d \
    -v dolibarr:/var/www/html \
    -v apps:/var/www/html/custom \
    -v config:/var/www/html/conf \
    -v theme:/var/www/html/theme/<YOUR_CUSTOM_THEME> \
    -e DOLI_AUTO_CONFIGURE='' \
    monogramm/docker-dolibarr

Auto configuration via environment variables

The Dolibarr image supports auto configuration via environment variables. You can preconfigure nearly everything that is asked on the install page on first run. To enable auto configuration, set your database connection via the following environment variables. ONLY use one database type!

See conf.php.example and install.forced.sample.php for more details on install configuration.

DOLI_AUTO_CONFIGURE

Default value: 1

Possible values: 1, ''

This parameter triggers the Dolibarr default configuration generation based on environment variables.

Examples:

    DOLI_AUTO_CONFIGURE=1
    DOLI_AUTO_CONFIGURE=''

DOLI_DB_TYPE

Default value: mysqli

Possible values: mysqli, pgsql

This parameter contains the name of the driver used to access your Dolibarr database.

Examples:

    DOLI_DB_TYPE=mysqli
    DOLI_DB_TYPE=pgsql

DOLI_DB_HOST

Default value:

This parameter contains host name or ip address of Dolibarr database server.

Examples:

    DOLI_DB_HOST=localhost
    DOLI_DB_HOST=127.0.2.1
    DOLI_DB_HOST=192.168.0.10
    DOLI_DB_HOST=mysql.myserver.com

DOLI_DB_PORT

Default value: 3306

This parameter contains the port of the Dolibarr database.

Examples:

    DOLI_DB_PORT=3306
    DOLI_DB_PORT=5432

DOLI_DB_NAME

Default value: dolibarr

This parameter contains name of Dolibarr database.

Examples:

    DOLI_DB_NAME=dolibarr
    DOLI_DB_NAME=mydatabase

DOLI_DB_USER

Default value: dolibarr

This parameter contains user name used to read and write into Dolibarr database.

Examples:

    DOLI_DB_USER=admin
    DOLI_DB_USER=dolibarruser

DOLI_DB_PASSWORD

Default value:

This parameter contains password used to read and write into Dolibarr database.

Examples:

    DOLI_DB_PASSWORD=myadminpass
    DOLI_DB_PASSWORD=myuserpassword

DOLI_DB_PREFIX

Default value: llx_

This parameter contains prefix of Dolibarr database.

Examples:

    DOLI_DB_PREFIX=llx_

DOLI_DB_CHARACTER_SET

Default value: utf8

Database character set used to store data (forced during database creation. value of database is then used). Depends on database driver used. See DOLI_DB_TYPE.

Examples:

    DOLI_DB_CHARACTER_SET=utf8

DOLI_DB_COLLATION

Default value: utf8_unicode_ci

Database collation used to sort data (forced during database creation. value of database is then used). Depends on database driver used. See DOLI_DB_TYPE.

Examples:

    DOLI_DB_COLLATION=utf8_unicode_ci

DOLI_DB_ROOT_LOGIN

Default value:

This parameter contains the database server root username used to create the Dolibarr database.

If this parameter is set, the container will automatically tell Dolibarr to create the database on first install with the root account.

Examples:

    DOLI_DB_ROOT_LOGIN=root
    DOLI_DB_ROOT_LOGIN=dolibarruser

DOLI_DB_ROOT_PASSWORD

Default value:

This parameter contains the database server root password used to create the Dolibarr database.

Examples:

    DOLI_DB_ROOT_PASSWORD=myrootpass

DOLI_ADMIN_LOGIN

Default value: admin

This parameter contains the admin's login used in the first install.

Examples:

    DOLI_ADMIN_LOGIN=admin

DOLI_MODULES

Default value:

This parameter contains the list (comma separated) of modules to enable in the first install.

Examples:

    DOLI_MODULES=modSociete
    DOLI_MODULES=modSociete,modPropale,modFournisseur,modContrat,modLdap

DOLI_URL_ROOT

Default value: http://localhost

This parameter defines the root URL of your Dolibarr index.php page without ending "/". It must link to the directory htdocs. In most cases, this is autodetected but it's still required

  • to show full url bookmarks for some services (ie: agenda rss export url, ...)
  • or when using Apache dir aliases (autodetect fails)
  • or when using nginx (autodetect fails)

Examples:

    DOLI_URL_ROOT=http://localhost
    DOLI_URL_ROOT=http://mydolibarrvirtualhost
    DOLI_URL_ROOT=http://myserver/dolibarr/htdocs
    DOLI_URL_ROOT=http://myserver/dolibarralias

DOLI_AUTH

Default value: dolibarr

Possible values: Any values found in files in htdocs/core/login directory after the function_ string and before the .php string, except forceuser. You can also separate several values using a ,. In this case, Dolibarr will check login/pass for each value in order defined into value. However, note that this can't work with all values.

This parameter contains the way authentication is done. Will not be used if you use first install wizard. See First use for more details.

If value ldap is used, you must also set parameters DOLI_LDAP_* and DOLI_MODULES must contain modLdap.

Examples:

    DOLI_AUTH=http
    DOLI_AUTH=dolibarr
    DOLI_AUTH=ldap
    DOLI_AUTH=openid,dolibarr

DOLI_LDAP_HOST

Default value:

You can define several servers here separated with a comma.

Examples:

    DOLI_LDAP_HOST=localhost
    DOLI_LDAP_HOST=ldap.company.com
    DOLI_LDAP_HOST=ldaps://ldap.company.com:636,ldap://ldap.company.com:389

DOLI_LDAP_PORT

Default value: 389

DOLI_LDAP_VERSION

Default value: 3

DOLI_LDAP_SERVERTYPE

Default value: openldap Possible values: openldap, activedirectory or egroupware

DOLI_LDAP_DN

Default value:

Examples:

    DOLI_LDAP_DN=ou=People,dc=company,dc=com

DOLI_LDAP_LOGIN_ATTRIBUTE

Default value: uid

Ex: uid or samaccountname for active directory

DOLI_LDAP_FILTER

Default value:

If defined, the two previous parameters are not used to find a user into LDAP.

Examples:

    DOLI_LDAP_FILTER=(uid=%1%)
    DOLI_LDAP_FILTER=(&(uid=%1%)(isMemberOf=cn=Sales,ou=Groups,dc=company,dc=com))

DOLI_LDAP_ADMIN_LOGIN

Default value:

Required only if anonymous bind disabled.

Examples:

    DOLI_LDAP_ADMIN_LOGIN=cn=admin,dc=company,dc=com

DOLI_LDAP_ADMIN_PASS

Default value:

Required only if anonymous bind disabled. Ex:

Examples:

    DOLI_LDAP_ADMIN_PASS=secret

DOLI_LDAP_DEBUG

Default value: false

DOLI_PROD

Default value: 0

Possible values: 0 or 1

When this parameter is defined, all errors messages are not reported. This feature exists for production usage to avoid to give any information to hackers.

Examples:

    DOLI_PROD=0
    DOLI_PROD=1

DOLI_HTTPS

Default value: 0

Possible values: 0, 1, 2 or https://my.domain.com

This parameter allows to force the HTTPS mode.

  • 0 = No forced redirect
  • 1 = Force redirect to https, until SCRIPT_URI start with https into response
  • 2 = Force redirect to https, until SERVER["HTTPS"] is 'on' into response
  • https://my.domain.com = Force redirect to https using this domain name.

Warning: If you enable this parameter, your web server must be configured to respond URL with https protocol. According to your web server setup, some values may work and other not. Try different values (1, 2 or https://my.domain.com) if you experience problems.

Examples:

    DOLI_HTTPS=0
    DOLI_HTTPS=1
    DOLI_HTTPS=2
    DOLI_HTTPS=https://my.domain.com

DOLI_NO_CSRF_CHECK

Default value: 0

Possible values: 0, 1

This parameter can be used to disable CSRF protection.

This might be required if you access Dolibarr behind a proxy that make URL rewriting, to avoid false alarms.

Examples:

    DOLI_NO_CSRF_CHECK=0
    DOLI_NO_CSRF_CHECK=1

PHP_INI_DATE_TIMEZONE

Default value: UTC

Default timezone on PHP.

PHP_MEMORY_LIMIT

Default value: 256M

Default memory limit on PHP.

PHP_MAX_UPLOAD

Default value: 20M

Default max upload size on PHP.

PHP_MAX_EXECUTION_TIME

Default value: 300

Default max execution time (in seconds) on PHP.

WWW_USER_ID

Default value: 33

ID of user www-data. ID will not change if left empty. During development, it is very practical to put the same ID as the host user.

WWW_GROUP_ID

Default value: 33

ID of group www-data. ID will not change if left empty.

Running this image with docker-compose

Base version - apache with MariaDB/MySQL

This version will use the apache image and add a MariaDB container (you can also use MySQL if you prefer). The volumes are set to keep your data persistent. This setup provides no ssl encryption and is intended to run behind a proxy.

Make sure to set the variables MYSQL_ROOT_PASSWORD, MYSQL_PASSWORD, DOLI_DB_PASSWORD before you run this setup.

Create docker-compose.yml file using docker-compose_apache.yml as template.

Then run all services docker-compose up -d. Now, go to http://localhost:80/install to access the new Dolibarr installation wizard. In this example, the Dolibarr scripts, documents, HTML and database will all be stored locally in the following folders:

  • /srv/dolibarr/html
  • /srv/dolibarr/scripts
  • /srv/dolibarr/documents
  • /srv/dolibarr/db

Base version - FPM with PostgreSQL

When using the FPM image you need another container that acts as web server on port 80 and proxies the requests to the Dolibarr container. In this example a simple nginx container is combined with the monogramm/docker-dolibarr-fpm image and a PostgreSQL database container. The data is stored in docker volumes. The nginx container also need access to static files from your Dolibarr installation. It gets access to all the volumes mounted to Dolibarr via the volumes_from option. The configuration for nginx is stored in the configuration file nginx.conf, that is mounted into the container.

As this setup does not include encryption it should to be run behind a proxy.

Make sure to set the variables POSTGRES_PASSWORD and DOLI_DB_PASSWORD before you run this setup.

Create docker-compose.yml file using docker-compose_fpm.yml as template.

Here is a sample nginx.conf file expected to be in the same folder:

    server {
        listen 80;
        server_name ${NGINX_HOST};

        root /var/www/html;
        index index.php;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        location / {
            try_files $uri $uri/ index.php;
        }

        location ~ [^/]\.php(/|$) {
            # try_files $uri =404;
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;
            fastcgi_pass dolibarr:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }

        location /api {
            if ( !-e $request_filename) {
                rewrite ^.* /api/index.php last;
            }
        }

    }

Then run all services docker-compose up -d. Now, go to http://localhost:80/install to access the new Dolibarr installation wizard. In this example, the Dolibarr scripts, documents, HTML and database will all be stored in Docker's default location. Feel free to edit this as you see fit.

Make your Dolibarr available from the internet

Until here your Dolibarr is just available from you docker host. If you want you Dolibarr available from the internet adding SSL encryption is mandatory.

HTTPS - SSL encryption

There are many different possibilities to introduce encryption depending on your setup.

We recommend using a reverse proxy in front of our Dolibarr installation. Your Dolibarr will only be reachable through the proxy, which encrypts all traffic to the clients. You can mount your manually generated certificates to the proxy or use a fully automated solution, which generates and renews the certificates for you.

First use

When you first access your Dolibarr, you need to access the install wizard at http://localhost/install/. The setup wizard will appear and ask you to choose an administrator account, password and the database connection. For the database use the name of your database container as host and dolibarr as table and user name. Also enter the database password you chose in your docker-compose.yml file.

Most of the fields of the wizard can be initialized with the environment variables.

You should note though that some environment variables will be ignored during install wizard (DOLI_AUTH and DOLI_LDAP_* for instance). An initial conf.php was generated by the container on the first start with the Dolibarr environment variables you set through Docker. To use the container generated configuration, you can skip the first step of install and go directly to http://localhost:8080/install/step2.php.

Update to a newer version

Updating the Dolibarr container is done by pulling the new image, throwing away the old container and starting the new one. Since all data is stored in volumes, nothing gets lost. The startup script will check for the version in your volume and the installed docker version. If it finds a mismatch, it automatically starts the upgrade process. Don't forget to add all the volumes to your new container, so it works as expected. Also, we advised you do not skip major versions during your upgrade. For instance, upgrade from 5.0 to 6.0, then 6.0 to 7.0, not directly from 5.0 to 7.0.

$ docker pull monogramm/docker-dolibarr
$ docker stop <your_dolibarr_container>
$ docker rm <your_dolibarr_container>
$ docker run <OPTIONS> -d monogramm/docker-dolibarr

Beware that you have to run the same command with the options that you used to initially start your Dolibarr. That includes volumes, port mapping.

When using docker-compose your compose file takes care of your configuration, so you just have to run:

$ docker-compose pull
$ docker-compose up -d

Adding Features

If the image does not include the packages you need, you can easily build your own image on top of it. Start your derived image with the FROM statement and add whatever you like.

FROM monogramm/docker-dolibarr:apache

RUN ...

You can also clone this repository and use the update.sh shell script to generate a new Dockerfile based on your own needs.

For instance, you could build a container based on Dolibarr develop branch by setting the update.sh versions like this:

versions=( "develop" )

Then simply call update.sh script.

bash update.sh

Your Dockerfile(s) will be generated in the images/develop folder.

If you use your own Dockerfile you need to configure your docker-compose file accordingly. Switch out the image option with build. You have to specify the path to your Dockerfile. (in the example it's in the same directory next to the docker-compose file)

  app:
    build: .
    links:
      - db
    volumes:
      - data:/var/www/html/data
      - config:/var/www/html/config
      - apps:/var/www/html/apps
    restart: always

Updating your own derived image is also very simple. When a new version of the Dolibarr image is available run:

docker build -t your-name --pull .
docker run -d your-name

or for docker-compose:

docker-compose build --pull
docker-compose up -d

The --pull option tells docker to look for new versions of the base image. Then the build instructions inside your Dockerfile are run on top of the new image.

Questions / Issues

If you got any questions or problems using the image, please visit our Github Repository and write an issue.