Docker which by now should need no introduction - offers you an efficient, speedy way to port applications across systems and machines. It is light and lean, allowing you to quickly contain applications and run them within their own secure environments (via Linux Containers: LXC).
Tryton is a three-tiers high-level general purpose application platform written in Python and use Postgresql as database engine. Read more about tryton here.
Installing Docker on Ubuntu(Latest)
$ sudo apt-get update $ sudo apt-get install docker.io $ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
You can read more about installing docker here.
Create a Dockerfile for tryton docker image. This file will define what will be there inside your docker container.
Some good documentation on writing dockerfile can be found here.
Specify which base image to use to build new docker image. In most of the cases it will be an OS image, which will be pulled automatically from docker hub.
Here I am using latest Ubuntu as base and specify the maintainer of docker build.
FROM ubuntu:14.04 MAINTAINER Tarun Bhardwaj <email@example.com>
This step is optional but recommended. Its a good idea to pull latest updates ;):
RUN apt-get update
We will need
pip in future to install python packages:
RUN apt-get -y -q install python-setuptools RUN easy_install pip
trytond and its dependencies:
RUN apt-get -y -q install python-lxml RUN pip install 'trytond>=3.2,<3.3'
Since we want the uploaded files to persist even after the lifetime of a container, they should be stored on the host volume.
For this docker offers a convenient way to mount host directories as volumes.
Recommended alternative for persistent storage is to use Amazon S3 with trytond-attachment-s3 which is highly available document storage.
Though Dockerfile permits volumes to be mounted to be specified by the dockerfile, it is better to mount the volumes over the CLI.
Expose Tryton port
Expose tryton's default port out of container.
Add an entrypoint to run docker container as an executable.
Read more about entrypoint here.
With this dockerfile tryton will run on default configurations, for custom configuration which you will obviously need.
Create a custom trytond configuration file as sibling of Dockerfile
tryton-docker |-- Dockerfile `-- trytond.conf 0 directories, 2 files
Then add following line to Dockerfile. This will copy the trytond.conf to docker image's
/etc/trytond.conf which is default path for tryton configuration.
ADD trytond.conf /etc/trytond.conf
Now you are all set for creating a docker image.
docker build -t openlabs/tryton .
openlabs/tryton is a tag to this image and
. is path to directory containing Dockerfile.
** I think you should refer to the github repo, it always stays up-to-date.
To pull this image from docker hub:
docker pull openlabs/tryton
Tryton docker container in projects
Create new dockerfile for your project and use previously created docker image as a base image and add instructions to install your project module and dependencies.
FROM openlabs/tryton:3.2 RUN pip install "trytond_purchase" RUN pip install "trytond_sale_opportunity" ...
Build the image in same way
docker build -t projectx .
Yes, projectx is your project's name.
Create docker container
Create a new container using the image.
docker run -P 8000 projectx
-P 8000 binds the already exposed container port 8000 to host.
Time to open tryton client and start using your ERP in a container.
- Scaling your infrastructure.
- Using fig and orchard for orchestrating tryton deployments.