Create 5.8 image with debian10-slim

This commit is contained in:
Sergio Morillo 2021-02-02 23:47:07 +01:00
parent 70214cfc6d
commit 52643b9bb2
4 changed files with 72 additions and 76 deletions

View File

@ -1,87 +1,76 @@
# 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.4
ENV SERIES 5.8
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
FROM debian:10-slim
LABEL maintainer="Datalife <info@datalifeit.es>" \
org.label-schema.name="Tryton" \
org.label-schema.url="http://www.datalifeit.es/" \
org.label-schema.vendor="Datalife" \
org.label-schema.version="5.4" \
org.label-schema.version="5.8" \
org.label-schema.schema-version="1.0"
MAINTAINER datalife
ENV SERIES 5.4
ENV LANG en_US.UTF-8
ENV PYTHONIOENCODING=UTF-8
ENV SERIES 5.8
ENV LANG C.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}
&& mkdir /home/trytond/www \
&& mkdir -p /etc/python3 \
&& echo "[DEFAULT]\nbyte-compile = standard, optimize" \
> /etc/python3/debian_config
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
mercurial \
git \
vim \
python3 \
python3-pip \
python3-setuptools \
uwsgi \
uwsgi-plugin-python3 \
# trytond
python3-bcrypt \
python3-cffi \
python3-genshi \
python3-gevent \
python3-html2text \
python3-levenshtein \
python3-lxml \
python3-passlib \
python3-polib \
python3-psycopg2 \
python3-pydot \
python3-werkzeug \
python3-wrapt \
# modules
python3-dateutil \
python3-ldap3 \
python3-magic \
python3-ofxparse \
python3-pypdf2 \
python3-pysimplesoap \
python3-requests \
python3-simpleeval \
python3-tz \
python3-zeep \
&& rm -rf /var/lib/apt/lists/*
# Add local content to Docker
USER trytond
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 trytond
WORKDIR ${WORK_DIR}
RUN hg clone http://hg.tryton.org/trytond/ -b ${SERIES}
@ -89,24 +78,30 @@ RUN hg clone http://hg.tryton.org/trytond/ -b ${SERIES}
# Copy patches after clone
COPY --chown=trytond:trytond patches ${WORK_DIR}
USER root
RUN cd trytond \
&& python3.6 setup.py develop --user
&& python3 setup.py develop
# Clone and install proteus and dvconfig
RUN pip3.6 install --no-cache-dir "proteus == ${SERIES}.*" --user
RUN pip3.6 install git+https://gitlab.com/datalifeit/tryton-dvconfig.git --user
RUN pip3 install --no-cache-dir --install-option="-O1" \
"proteus == ${SERIES}.*" \
&& pip3 install --no-cache-dir --install-option="-O1" \
forex-python \
phonenumbers \
pycountry \
pygal \
python-stdnum[SOAP] \
# Use wheels as Debian compiled dependencies are too old
&& pip3 install --no-cache-dir weasyprint \
&& pip3 install git+https://gitlab.com/datalifeit/tryton-dvconfig.git
# 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
USER trytond
ENTRYPOINT ["/entrypoint.sh"]
CMD ["uwsgi", "--ini", "/home/trytond/tryton/etc/uwsgi.conf"]
CMD ["uwsgi", "--ini", "/home/trytond/tryton/etc/uwsgi.conf"]

View File

@ -1,2 +1,3 @@
[web]
listen=0.0.0.0:8000
listen=0.0.0.0:8000
root=/home/trytond/www

View File

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

View File

@ -1,6 +1,6 @@
[uwsgi]
http-socket=0.0.0.0:8000
master=true
plugins=python3
env=TRYTOND_CONFIG=$(TRYTOND_CONFIG)
env=TRYTOND_DATABASE_URI=$(TRYTOND_DATABASE_URI)
env=PYTHONOPTIMIZE=$(PYTHONOPTIMIZE)