Tryton for Dummies

This is good news!

For the aspect of maintainability, it would be better when you correct or append the existing documentation.

Hello,
After all I decided to give up on the first attempt and went for the Docker Image. That was much smoother and installed like a charm. My issue now is *how to connect the instance running to an external DB? I can’t have the database be running as an instance because if the PC goes down, it is all gone. Thank you in advance for your reply.

You need to set the following environment variables on the docker container:

  • DB_USER
  • DB_PASSWORD
  • DB_HOSTNAME
  • DB_PORT

If you use a volume for the postgres data you won’t lose anything.

Hi Pokoli,
Thank you for your suggestion. I got a little help from a friend and was able to make a few changes to the set up and made it happen. I however am stumped because of the inability to access the DB.

Here is some screen shots:
Running instances
:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fe76dc97b5cb tryton/tryton “/entrypoint.sh guni…” 3 days ago Up 3 days 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp tryton
63d86a4b665b postgres “docker-entrypoint.s…” 3 days ago Up 3 days 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp tryton-postgres

image
using localhost:8000 doesn’t get me far because there is no DB selection in the dropdown menu. I have 2 DBs running as you may be able see here:


What am I missing or haven’t done?

below is a run down of how i got all this to work so far:
Links used:

https://hub.docker.com/r/tryton/tryton

1- Clean Ubuntu Install

2- Update install using : sudo apt-get update

3- install docker using: sudo apt install docker.io then answer Y when prompted

4- Create the docker group.
sudo groupadd docker

  • Add your user to the docker group.
    sudo usermod -aG docker $USER

* Log out and log back in so that your group membership is re-evaluated.

> If you're running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.

You can also run the following command to activate the changes to groups:
newgrp docker

* Verify that you can run `docker` commands without `sudo`.
docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.

5- Download Tryton: docker pull tryton/tryton

6- Start a PostgreSQL instance:

docker run --name tryton-postgres -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=tryton -d postgres

7- Setup the Database:

docker run --link tryton-postgres:postgres -e DB_PASSWORD=mysecretpassword -it tryton/tryton trytond-admin -d tryton --all

8- Enter admin email for tryton: email of choice
9- Enter 
a password for the tryton admin: ```
10- Start a Tryton Instance:
docker run --name tryton -p 8000:8000 --link tryton-postgres:postgres -e DB_PASSWORD=mysecretpassword -d tryton/tryton

11- Access Tryton using the URL: 
http://localhost:8000
12- To Check on Running Containers, run:
docker ps


The following is PGadmin4 installation steps:

1- Install curl:

sudo snap install curl # version 8.1.2

2- Setup the repository

A- Install the public key for the repository (if not done previously):

curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg

B -Create the repository configuration file:

sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin- org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

3- Install pgAdmin

# Install for both desktop and web modes:

sudo apt install pgadmin4

# Install for desktop mode only:

sudo apt install pgadmin4-desktop

# Install for web mode only:

sudo apt install pgadmin4-web

# Configure the webserver, if you installed pgadmin4-web:

sudo /usr/pgadmin4/bin/setup-web.sh

Enter the email address and password to use for the initial pgAdmin user account:
pgAdmin 4 - Application Initialisation

======================================

Creating storage and log directories...

We can now configure the Apache Web server for you. This involves enabling the wsgi module and configuring the pgAdmin 4 application to mount at /pgadmin4. Do you wish to continue (y/n)? y

The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? y

Apache successfully restarted. You can now start using pgAdmin 4 in web mode at **http://127.0.0.1/pgadmin4**

-------------------------------------------------------------------------------


The command below is how we managed to connect Tryton to an external database.

To start the docker container and mount the data, logs, and configuration:

**docker run --name tryton-postgres -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=tryton -d -v /home/ama/postgres-conf:/etc/postgresql -v /home/ama/postgres-data/data:/var/lib/postgresql/data -v postgres-logs:/var/log/postgresql -p 5432:5432 postgres*

ALTER ROLE

Important: we did couple of things to get the docker volume mount to work:

1- we changed the postgres user and group IDs to 999, to align the postgres user and group on the host to the one in the container.

2- We created /home/ama/postgres-data/data on localhost, chnaged its ownership to postgres:postgres, and mounted /home/ama/postgres-data/data.

3- We changed the ownership of /home/ama/postgres-data, /home/ama/postgres-conf, and /home/ama/postgres-logs to postgres:postgres.


I hope you can guide me to the next step. Thank you!

To me (just my personal opinion), the attempt of a docker install was a nightmare. If you are not familiar with docker, you need to learn much of it - which puts a big burden onto your onboarding process. I had to give in with it after weeks of struggle and frustration.

I’m very grateful that I was pointed to the Virtual Environments method, which I could handle well. But I could not understand why I should repeat so many commands over and over again, so I started to develop an install script. I don’t think it’s a good script, as it was my first programming project ever. Nevertheless it has proved to be useful in quite some cases by now. My friend @mstma is working on extending it to MacOS at the moment.

If you want to give it a try, find the latest version at Tryton community. Please apologize that messages are in German. As Mr. Kríer refuses to publish anything but the docker install method, I did not feel motivated to provide an English or Spanish version.

Cheers,
Wolf

1 Like

Simply because any attempt to make and maintain a generic (for any OS) install script will lead to basically recreate docker (or any other existing container).

2 Likes

I will not comment any further here - and rather write an “Installation” section at Tryton community wiki some time.

1 Like

Gentlemen, Thank you both for your replies. I tried the virtual environment and it was great for as long as It lasted. One update and it all went south for me. Docker is a breeaze compared to the VE in my personal opinion. I however was hoping for a solution to my problem. Thank you!

What is your problem exactly? Because frankly I do not understand you post (the formatting is very weird).

Gnu Health provides an installer, see their download page. Maybe this would be an idea for Tryton, too?

(major editing after actually reading some of the scripts… :wink: )

Are you referring to the gnuhealth-setup shell script? I downloaded the installer (.tar.gz) but didn’t perform an actual installation. Unless I’m missing something, the GNU Health scripts install a required set of trytond modules (as well as their own modules) after trytond has already been installed and configured (including installing and configuring a production server stack and PostgreSQL).

I’m not convinced the typical user of the GNU Health installer is the same as their Tryton counterpart.

Also, re Docker, I think Docker containers are probably very convenient for Tryton service providers to manage several or more client-specific systems. A docker container is also convenient for someone to get Tryton running on a vanilla Linux laptop or VPS, but it is not necessarily convenient for that person to manage their system, and therein lies a paradox.

@herrdeh mentioned in his post an installation script for Tryton and that a version for Mac OS X is in work. Now this version is available in a separate branch “os x” in the the repository at Tryton community, see

tryton-installation-and-maintainance-scripts-for-pip-venv

It’s just work in progress and it is based on MacPorts.