This post kicks of a new series on the Tryton FOSS ERP system. Today’s quick post is about installing Tryton as a docker stack. As usual, the most tricky part is to come up with a functioning docker-compose.yml
file.
Useful resources
Most online documentations I came across are geared towards running Tryton as separate Docker containers via the docker run
command rather than as a stack via docker compose
. Even the instructions for the tryton/tryton repository on the Docker hub are quite thin-lipped when it comes to docker compose. The reader is mainly referred to a sample compose.yml
file which I could not get working.
The best point to start from I could find is a docker-compose.yml file from the tryton-docker-compose repo on GitHub by user Chris927, which again was forked from Eric Hemmerlin’s tryton repo on GitHub.
Step by step installation
1. Prepare a docker-compose.yml
file
This is by far the most important step. As already mentioned, we start from the template provided by GitHub user Chris927. The things we modify are:
Warning messages issued by postgres service
The command for running the healthcheck test of the postgres
service produces a series of debug messages Fatal: role "root" does not exist
. The reason these warnings pop up is that the following line fails:
1 |
test: ["CMD-SHELL", "pg_isready", "-h", "localhost", "-p", "5432", "-U", "healthcheck-user"] |
There is a discussion on how to appropriately expand environment variables in docker YAML files (not sure if it’s only related to the healthcheck feature or a general problem). The suggestion which solved the issue for me was to change the line as follows:
1 2 3 |
healthcheck: test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] interval: 3s |
Removal of mailhog service
I don’t know much about the purpose of the mailhog
service which is included in the original compose file. On its GitHub page, mailhog
is – among others – described as an “email testing tool for developers”.
As our aim is to come up with a dockerized Tryton for production and not for development purposes and as for the time being, there is no evidence of an extensive need for operating SMTP services out of Tryton, I removed the complete mailhog
section from the services list of the docker-compose.yaml
file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
services: postgres: image: postgres:${POSTGRES_VERSION:-latest} environment: - POSTGRES_DB=${POSTGRES_DB:-tryton} - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} volumes: - db:/var/lib/postgresql/data restart: always healthcheck: test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] interval: 3s timeout: 5s retries: 15 app: image: tryton/tryton:${TRYTON_TAG} environment: - TRYTOND_EMAIL__FROM=${EMAIL_FROM} - TRYTOND_DATABASE__URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres/${POSTGRES_DB} ports: - "8000:8000" volumes: - data:/var/lib/trytond/db depends_on: postgres: condition: service_healthy restart: always cron: image: tryton/tryton:${TRYTON_TAG} command: trytond-cron --dev -v environment: - TRYTOND_DATABASE__URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres/${POSTGRES_DB} volumes: - data:/var/lib/trytond/db depends_on: postgres: condition: service_healthy update: image: tryton/tryton:${TRYTON_TAG} command: sh -c "trytond-admin -d ${POSTGRES_DB} --all -v && tail -f /dev/null" environment: - TRYTOND_DATABASE__URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres/${POSTGRES_DB} volumes: - data:/var/lib/trytond/db depends_on: postgres: condition: service_healthy restart: "no" volumes: db: {} data: {} |
2. Prepare the .env
file
While most environment variables in the docker-compose.yml file come with a default value, it looks reasonable to set some values in the .env file:
1 2 3 4 5 6 |
TRYTON_TAG=7.0 POSTGRES_VERSION=16 POSTGRES_DB=tryton POSTGRES_USER=ilek POSTGRES_PASSWORD=testing123 EMAIL_FROM=libudja@web.de |
3. Set up the admin user
Note that the POSTGRES_USER
and POSTGRES_PASSWORD
in the above .env
file are the credentials for the admin superuser of the Postgres database. They don’t have anything to do with the Tryton user authentication and authorization.
Start the docker stack by running docker compose up -d
.
You must set the login password for the Tryton (not postgres) admin user as shown below:
From the directory holding the docker-compose.yml
file, execute trytond-admin
to set the Tryton login password for the admin user:
1 |
docker exec -it tryton_chris972-app-1 trytond-admin -d tryton --password |
tryton_chris972-app-1
is the name of the Tryton container running the main Tryton app.-d tryton
specifies the name of the Tryton database as set in thePOSTGRES_DB
variable in the.env
file.
You will be asked to set a password for the Tryton superuser admin and confirm the password.
4. Initial login into Tryton as admin
The only combination of credentials that allow a login after a fresh installation are for user admin
and with the password you just set in step 3.
Initial login screen of Tryton after a fresh install
After entering the password in the next window, Tryton will walk you through a basic setup of your ERP. This however will be covered in a later blog post.
Having a closer look at the PostgreSQL database
You can access the PostgreSQL database directly from the command line with the following command:
1 |
$ docker exec -it tryton_chris972-postgres-1 psql -d tryton -U ilek |
tryton_chris972_postgres-1
is the name of the container running the PostgreSQL server-d tryton
is the Tryton database as specified in thePOSTGRES_DB
variable of your.env
file-U ilek
is the PostgreSQL admin user as specified in thePOSTGRES_USER
variable of your.env
file. Once again: The POSTGRES_USER is the superuser of the PostgreSQL server. It does not refer to any user that can log into the Tryton system.
Is it possible to run Tryton on a Raspberry Pi?
Running Tryton on a Raspberry Pi machine would require an image that has been compiled for the Raspberry’s ARM architecture. While there are some ARM images on the Docker hub, these are inofficial builds with sparse to non-existant maintenance and outdated versions. I would therefore not recommend to run Tryton on such a machine.