[ADD] Packaging: Debian and CentOS Dockerfiles for nightly builds tests

This way we'll be using docker cache to spare dependencies download time.
This commit is contained in:
Aaron Bohy 2014-12-05 10:17:53 +01:00 committed by Simon Lejeune
parent a700a1139e
commit a7ab5a4109
3 changed files with 142 additions and 22 deletions

49
setup/package.dfcentos Normal file
View File

@ -0,0 +1,49 @@
# Please note that this Dockerfile is used for testing nightly builds and should
# not be used to deploy Odoo
FROM centos:centos7
MAINTAINER Odoo S.A. <info@odoo.com>
# Dependencies and postgres
RUN yum install -d 0 -e 0 epel-release -y && \
yum update -d 0 -e 0 -y && \
yum install -d 0 -e 0 \
babel \
libxslt-python \
pychart \
pyparsing \
python-dateutil \
python-decorator \
python-docutils \
python-feedparser \
python-imaging \
python-jinja2 \
python-ldap \
python-lxml \
python-mako \
python-mock \
python-openid \
python-passlib \
python-psutil \
python-psycopg2 \
python-reportlab \
python-requests \
python-simplejson \
python-unittest2 \
python-vobject \
python-werkzeug \
python-yaml \
pytz \
postgresql \
postgresql-server \
postgresql-libs \
postgresql-contrib \
postgresql-devel -y && \
yum clean all
RUN easy_install pyPdf vatnumber pydot psycogreen
# Manual start of postgres
RUN mkdir -p /var/lib/postgres/data
RUN chown -R postgres:postgres /var/lib/postgres/data
RUN su postgres -c "initdb -D /var/lib/postgres/data -E UTF-8"
RUN cp /usr/share/pgsql/postgresql.conf.sample /var/lib/postgres/data/postgresql.conf

70
setup/package.dfdebian Normal file
View File

@ -0,0 +1,70 @@
# Please note that this Dockerfile is used for testing nightly builds and should
# not be used to deploy Odoo
FROM debian:stable
MAINTAINER Odoo S.A. <info@odoo.com>
# Change policy-rc.d so that services start automatically once installed
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d
RUN apt-get update && \
apt-get install -y locales && \
rm -rf /var/lib/apt/lists/*
# Reconfigure locales such that postgresql uses UTF-8 encoding
RUN dpkg-reconfigure locales && \
locale-gen C.UTF-8 && \
/usr/sbin/update-locale LANG=C.UTF-8
ENV LC_ALL C.UTF-8
RUN apt-get update -qq && \
apt-get upgrade -qq -y && \
apt-get install \
postgresql \
postgresql-server-dev-all \
postgresql-client \
adduser \
libxml2-dev \
libxslt1-dev \
libldap2-dev \
libsasl2-dev \
libssl-dev \
libjpeg-dev \
python-dev \
python-pip \
build-essential \
python \
python-dateutil \
python-decorator \
python-docutils \
python-feedparser \
python-imaging \
python-jinja2 \
python-ldap \
python-libxslt1 \
python-lxml \
python-mako \
python-mock \
python-openid \
python-passlib \
python-psutil \
python-psycopg2 \
python-pybabel \
python-pychart \
python-pydot \
python-pyparsing \
python-pypdf \
python-reportlab \
python-requests \
python-simplejson \
python-tz \
python-unittest2 \
python-vatnumber \
python-vobject \
python-werkzeug \
python-xlwt \
python-yaml -y && \
rm -rf /var/lib/apt/lists/*
COPY requirements.txt /opt/release/requirements.txt
RUN pip install -r /opt/release/requirements.txt

View File

@ -298,15 +298,27 @@ def build_exe(o):
#----------------------------------------------------------
# Stage: testing
#----------------------------------------------------------
def _prepare_testing(o):
if not o.no_tarball or not o.no_debian:
subprocess.call(["mkdir", "docker_debian"], cwd=o.build_dir)
subprocess.call(["cp", "package.dfdebian", os.path.join(o.build_dir, "docker_debian", "Dockerfile")],
cwd=os.path.join(o.odoo_dir, "setup"))
# Use rsync to copy requirements.txt in order to keep original permissions
subprocess.call(["rsync", "-a", "requirements.txt", os.path.join(o.build_dir, "docker_debian")],
cwd=os.path.join(o.odoo_dir))
subprocess.call(["docker", "build", "-t", "odoo-debian-nightly-tests", "."],
cwd=os.path.join(o.build_dir, "docker_debian"))
if not o.no_rpm:
subprocess.call(["mkdir", "docker_centos"], cwd=o.build_dir)
subprocess.call(["cp", "package.dfcentos", os.path.join(o.build_dir, "docker_centos", "Dockerfile")],
cwd=os.path.join(o.odoo_dir, "setup"))
subprocess.call(["docker", "build", "-t", "odoo-centos-nightly-tests", "."],
cwd=os.path.join(o.build_dir, "docker_centos"))
def test_tgz(o):
with docker('debian:stable', o.build_dir, o.pub) as wheezy:
with docker('odoo-debian-nightly-tests', o.build_dir, o.pub) as wheezy:
wheezy.release = 'odoo.tar.gz'
wheezy.system('apt-get update -qq && apt-get upgrade -qq -y')
wheezy.system("apt-get install postgresql python-dev postgresql-server-dev-all python-pip build-essential libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libssl-dev libjpeg-dev -y")
wheezy.system("service postgresql start")
wheezy.system('su postgres -s /bin/bash -c "pg_dropcluster --stop 9.1 main"')
wheezy.system('su postgres -s /bin/bash -c "pg_createcluster --start -e UTF-8 9.1 main"')
wheezy.system('pip install -r /opt/release/requirements.txt')
wheezy.system('/usr/local/bin/pip install /opt/release/%s' % wheezy.release)
wheezy.system("useradd --system --no-create-home odoo")
wheezy.system('su postgres -s /bin/bash -c "createuser -s odoo"')
@ -317,13 +329,9 @@ def test_tgz(o):
wheezy.system('su odoo -s /bin/bash -c "odoo.py --addons-path=/usr/local/lib/python2.7/dist-packages/openerp/addons -d mycompany &"')
def test_deb(o):
with docker('debian:stable', o.build_dir, o.pub) as wheezy:
with docker('odoo-debian-nightly-tests', o.build_dir, o.pub) as wheezy:
wheezy.release = '*.deb'
wheezy.system('/usr/bin/apt-get update -qq && /usr/bin/apt-get upgrade -qq -y')
wheezy.system("apt-get install postgresql -y")
wheezy.system("service postgresql start")
wheezy.system('su postgres -s /bin/bash -c "pg_dropcluster --stop 9.1 main"')
wheezy.system('su postgres -s /bin/bash -c "pg_createcluster --start -e UTF-8 9.1 main"')
wheezy.system('su postgres -s /bin/bash -c "createdb mycompany"')
wheezy.system('/usr/bin/dpkg -i /opt/release/%s' % wheezy.release)
wheezy.system('/usr/bin/apt-get install -f -y')
@ -331,18 +339,9 @@ def test_deb(o):
wheezy.system('su odoo -s /bin/bash -c "odoo.py -c /etc/odoo/openerp-server.conf -d mycompany &"')
def test_rpm(o):
with docker('centos:centos7', o.build_dir, o.pub) as centos7:
with docker('odoo-centos-nightly-tests', o.build_dir, o.pub) as centos7:
centos7.release = 'odoo.noarch.rpm'
# Dependencies
centos7.system('yum install -d 0 -e 0 epel-release -y')
centos7.system('yum update -d 0 -e 0 -y')
# Manual install/start of postgres
centos7.system('yum install -d 0 -e 0 postgresql postgresql-server postgresql-libs postgresql-contrib postgresql-devel -y')
centos7.system('mkdir -p /var/lib/postgres/data')
centos7.system('chown -R postgres:postgres /var/lib/postgres/data')
centos7.system('chmod 0700 /var/lib/postgres/data')
centos7.system('su postgres -c "initdb -D /var/lib/postgres/data -E UTF-8"')
centos7.system('cp /usr/share/pgsql/postgresql.conf.sample /var/lib/postgres/data/postgresql.conf')
# Start postgresql
centos7.system('su postgres -c "/usr/bin/pg_ctl -D /var/lib/postgres/data start"')
centos7.system('sleep 5')
centos7.system('su postgres -c "createdb mycompany"')
@ -447,6 +446,8 @@ def options():
def main():
o = options()
_prepare_build_dir(o)
if not o.no_testing:
_prepare_testing(o)
try:
if not o.no_tarball:
build_tgz(o)