Initial commit

This commit is contained in:
Sergio Morillo 2019-04-29 12:00:17 +02:00
commit d3a91141e3
10 changed files with 193 additions and 0 deletions

22
.hgignore Normal file
View File

@ -0,0 +1,22 @@
syntax: glob
*.py{c,o}
dist/
build/
_build/
*.egg-info/
*.egg/
*.eggs/
.coverage
*,cover
*.rej
*.orig
*.jasper
node_modules/
bower_components/
.tox/
.git/
.review.cfg
.idea
.DS_Store
.~lock.*

5
.hgrc Normal file
View File

@ -0,0 +1,5 @@
[extensions]
color =
[ui]
ignore = ~/.hgignore

104
Dockerfile Normal file
View File

@ -0,0 +1,104 @@
# Dockerfile with:
# - CentOS 7
# - User trytond without password
# - Tryton server
# - Python 3
# - Tryton folder is copied to home folder
#
# Help:
# - You must add your config file own.cfg inside config folder
# - You must pass your ssh key when building image
#
# Build image with name tryton-centos and custom ssh:
# docker build --tag=tryton-centos --build-arg ssh_prv_key="$(cat ~/.ssh/id_rsa)" --build-arg ssh_pub_key="$(cat ~/.ssh/id_rsa.pub)" .
#
# Create container from tryton-centos with interactive shell:
# docker run --name tryton-shell -it --rm tryton-centos
FROM node as builder-node
ENV SERIES 5.0
RUN npm install -g bower
RUN curl https://downloads.tryton.org/${SERIES}/tryton-sao-last.tgz | tar zxf - -C /
RUN cd /package && bower install --allow-root
FROM centos:7
LABEL maintainer="Datalife <info@datalife.com.es>" \
org.label-schema.name="Tryton" \
org.label-schema.url="http://www.datalife.com.es/" \
org.label-schema.vendor="Datalife" \
org.label-schema.version="5.0" \
org.label-schema.schema-version="1.0"
MAINTAINER datalife
ENV SERIES 5.0
ENV LANG en_US.UTF-8
ENV PYTHONIOENCODING=UTF-8
ENV USER="trytond"
ENV HOME_DIR="/home/${USER}"
ENV WORK_DIR="${HOME_DIR}/tryton"
ARG ssh_prv_key
ARG ssh_pub_key
# Install libraries
RUN yum -y update
RUN yum -y install \
mercurial \
git \
cairo \
pango \
redhat-rpm-config \
sudo \
libxslt \
libxslt-devel \
libxml2 \
libxml2-python \
gcc-c++ \
policycoreutils-python \
pcre \
pcre-devel \
epel-release
RUN yum -y install \
python36 \
python36-devel \
python36-psycopg2
RUN python3.6 -m ensurepip
RUN pip3.6 install \
invoke \
uwsgi
# Create user trytond without password
RUN groupadd -r trytond \
&& useradd --no-log-init -r -m -g trytond trytond \
&& mkdir /home/trytond/tryton && chown trytond:trytond /home/trytond/tryton \
&& mkdir /home/trytond/db && chown trytond:trytond /home/trytond/db \
&& mkdir /home/trytond/www
RUN usermod -aG wheel ${USER}
# Add local content to Docker
COPY --chown=trytond:trytond content ${WORK_DIR}
COPY --chown=trytond:trytond ./.hgrc ${HOME_DIR}
COPY --chown=trytond:trytond ./.hgignore ${HOME_DIR}
USER ${USER}
# Clone and install the repositories: trytond, proteus and dvconfig
WORKDIR ${WORK_DIR}
RUN hg clone http://hg.tryton.org/trytond/ -b ${SERIES} && cd trytond && python3.6 setup.py develop --user
RUN pip3.6 install --no-cache-dir "proteus == ${SERIES}.*" --user
RUN pip3.6 install hg+https://bitbucket.org/datalife_sco/tryton-dvconfig --user
# Local bin path to have access to pip user modules
ENV PATH="~/.local/bin:${PATH}"
# Install SAO
COPY --from=builder-node /package /home/trytond/www
# Expose service trytond
COPY entrypoint.sh /
COPY uwsgi.conf ${WORK_DIR}/etc/uwsgi.conf
EXPOSE 8000
VOLUME ["/home/trytond/db", "/home/trytond/tryton"]
ENV TRYTOND_CONFIG=${WORK_DIR}/etc/trytond.conf
ENTRYPOINT ["/entrypoint.sh"]
CMD ["uwsgi", "--ini", "/home/trytond/tryton/etc/uwsgi.conf"]

0
content/config/.hgempty Normal file
View File

2
content/etc/trytond.conf Normal file
View File

@ -0,0 +1,2 @@
[web]
listen=0.0.0.0:8000

7
content/tasks.py Normal file
View File

@ -0,0 +1,7 @@
# The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from invoke import Collection
import tryton_dv
ns = Collection()
ns.add_collection(Collection.from_module(tryton_dv, name='scm'))

19
entrypoint.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -e
: ${DB_USER:=${POSTGRES_ENV_POSTGRES_USER:='postgres'}}
: ${DB_PASSWORD:=${POSTGRES_ENV_POSTGRES_PASSWORD}}
: ${DB_HOSTNAME:=${POSTGRES_PORT_5432_TCP_ADDR:='postgres'}}
: ${DB_PORT:=${POSTGRES_PORT_5432_TCP_PORT:='5432'}}
: ${TRYTOND_DATABASE_URI:="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOSTNAME}:${DB_PORT}/"}
: ${PYTHONOPTIMIZE:=1}
# Remove PYTHONOPTIMIZE to get working asserts
export TRYTOND_DATABASE_URI
if [ "${1:0:1}" = '-' ]; then
set -- uwsgi --ini /home/trytond/tryton/etc/uwsgi.conf "$@"
fi
exec "$@"

13
office/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM datalife/tryton:5.0
LABEL org.label-schema.version="5.0-office"
USER root
RUN yum install -y \
libreoffice-core \
libreoffice-common \
libreoffice-base \
libreoffice-writer \
libreoffice-math
USER trytond

9
update.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/sh
docker build -q --rm --no-cache -t datalife/tryton:5.0 -t datalife/tryton:latest .
docker build -q --rm --no-cache -t datalife/tryton:5.0-office -t datalife/tryton:office office
docker push datalife/tryton:5.0-office
docker push datalife/tryton:5.0
docker push datalife/tryton:office
docker push datalife/tryton:latest

12
uwsgi.conf Normal file
View File

@ -0,0 +1,12 @@
[uwsgi]
http-socket=0.0.0.0:8000
master=true
env=TRYTOND_CONFIG=$(TRYTOND_CONFIG)
env=TRYTOND_DATABASE_URI=$(TRYTOND_DATABASE_URI)
# comment to get asserts working
#env=PYTHONOPTIMIZE=$(PYTHONOPTIMIZE)
wsgi=trytond.application:app
cheaper=1
processes=8
# comment for problems with CIL
#threads=8