Skip to content

Commit

Permalink
Dockerfile to build Odoo v7 based on Odoo OCB code
Browse files Browse the repository at this point in the history
  • Loading branch information
seb-elico committed Sep 25, 2015
1 parent 6ed36d9 commit 93d045c
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 0 deletions.
86 changes: 86 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
FROM ubuntu:14.04
MAINTAINER Elico-Corp <info@elico-corp.com>

# generate locales
RUN locale-gen en_US.UTF-8 && update-locale
RUN echo 'LANG="en_US.UTF-8"' > /etc/default/locale

# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8

# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, ``9.4``.
# install dependencies as distrib packages when system bindings are required
# some of them extend the basic odoo requirements for a better "apps" compatibility
# most dependencies are distributed as wheel packages at the next step
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
apt-get update && \
apt-get -yq install \
adduser \
ghostscript \
postgresql-client-9.4 \
python \
python-pip \
python-imaging \
python-pychart python-libxslt1 xfonts-base xfonts-75dpi \
libxrender1 libxext6 fontconfig \
python-zsi \
python-lasso \
# SM: libpq-dev is needed to install pg_config which is required by psycopg2
libpq-dev \
# SM: These libraries are needed to install the pip modules
python-dev \
libffi-dev \
libxml2-dev \
libxslt1-dev \
libldap2-dev \
libsasl2-dev \
libssl-dev \
# SM: This library is necessary to upgrade PIL/pillow module
libjpeg8-dev \
# SM: Git is required to clone Odoo OCB project
git

ADD sources/pip-req.txt /opt/sources/pip-req.txt

# SM: Install Odoo python dependencies
RUN pip install -r /opt/sources/pip-req.txt

# SM: Upgrade pillow to allow JPEG resize operations (used by demo data)
RUN pip install -i --upgrade pillow

# must unzip this package to make it visible as an odoo external dependency
RUN easy_install -UZ py3o.template

# install wkhtmltopdf based on QT5
# SM: do not use latest version (0.12.2.1) because it causes the footer issue (see https://github.com/odoo/odoo/issues/4806)
ADD http://download.gna.org/wkhtmltopdf/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb /opt/sources/wkhtmltox.deb
RUN dpkg -i /opt/sources/wkhtmltox.deb

# create the odoo user
RUN adduser --home=/opt/odoo --disabled-password --gecos "" --shell=/bin/bash odoo

# changing user is required by openerp which won't start with root
# makes the container more unlikely to be unwillingly changed in interactive mode
USER odoo

RUN /bin/bash -c "mkdir -p /opt/odoo/{bin,etc,sources/odoo,additional_addons,data}"
RUN /bin/bash -c "mkdir -p /opt/odoo/var/{run,log,egg-cache}"

# SM: Add Odoo OCB sources (remove .git folder to reduce image size)
WORKDIR /opt/odoo/sources
RUN git clone https://github.com/OCA/OCB.git -b 7.0 odoo && \
rm -rf odoo/.git

# Execution environment
USER 0
ADD sources/odoo.conf /opt/sources/odoo.conf
WORKDIR /app
VOLUME ["/opt/odoo/var", "/opt/odoo/etc", "/opt/odoo/additional_addons", "/opt/odoo/data"]
# Set the default entrypoint (non overridable) to run when starting the container
ENTRYPOINT ["/app/bin/boot"]
CMD ["help"]
# Expose the odoo ports (for linked containers)
EXPOSE 8069 8072
ADD bin /app/bin/
68 changes: 68 additions & 0 deletions bin/boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
#
# This script is designed to be run inside the container
#

# fail hard and fast even on pipelines
set -eo pipefail

function help {
set +e
cat bin/help.txt

This comment has been minimized.

Copy link
@rriemann

rriemann Nov 27, 2015

There is no help.txt in the bin folder of this repo. Is this on purpose?

This comment has been minimized.

Copy link
@elicoidal

elicoidal Nov 28, 2015

Contributor

@rriemann we are still in work in progress. It should come soon

set -e
}

function login {
echo "Running bash"
set +e
if [[ ! -e $1 && $1 = "root" ]]; then
/bin/bash
else
sudo su - odoo
fi
SERVICE_PID=$!
set -e
}

function start {
echo "Running odoo..."
set +e
if [ ! -e $1 ]; then
echo "...with additional args: $*"
fi
sudo -i -u odoo /usr/bin/python \
/opt/odoo/sources/odoo/openerp-server \
-c $file \
$*

SERVICE_PID=$!
set -e
}

# smart shutdown on SIGINT and SIGTERM
function on_exit() {
kill -TERM $SERVICE_PID
wait $SERVICE_PID 2>/dev/null
exit 0
}
trap on_exit INT TERM

echo "Search conf file"
if [[ -z "$ODOO_CONF" ]];
then
file="/opt/odoo/etc/odoo.conf"
else
file=$ODOO_CONF
fi
if [ ! -f "$file" ]; then
cp /opt/sources/odoo.conf $file
echo "Copy template as conf file $file"
fi
chown -R odoo /opt/odoo

This comment has been minimized.

Copy link
@yostashiro

yostashiro Aug 4, 2016

I guess this step should not be needed if you sync UID and GID of odoo between container and host.

In our practice, we run addgroup --gid=300 odoo && adduser --system --uid=300 --gid=300 --home /opt/odoo --shell /bin/bash odoo in both Docker image build and the host, so that we avoid having to run chown -R odoo /opt/odoo every time the container starts.

echo "Running command..."
for arg in "$*"
do
$arg
done

wait
24 changes: 24 additions & 0 deletions bin/help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Usage: docker run [OPTIONS] xcgd/odoo[:TAG] [COMMAND ...]

Run odoo in a docker container.

Positional arguments:
COMMAND The command to run. (default: help)

Commands:
help Show this help message
start Run odoo server in the background (accept additional arguments passed to odoo command)
login Run in shell mode as odoo user

Examples:
In these examples, we link to a container named "pg93" which serves PostreSQL (see xcgd/postgresql)

Run odoo V7 in the background as "xcgd.odoo" on localhost:8069 and use /your/local/etc/ to load odoo.conf
$ docker run --name="xcgd.odoo" -v /your/local/etc:/opt/odoo/etc -p 8069:8069 --link pg93:db -d xcgd/odoo:7.0 start

Run the V8 image with an interactive shell and remove the container on logout
$ docker run -ti --rm --link pg93:db xcgd/odoo:8.0 login

Run the v8 image and enforce a database `mydb` update, then remove the container
$ docker run -ti --rm --link pg93:db xcgd/odoo:8.0 start --update=all --workers=0 --no-xmlrpc --database=mydb --stop-after-init

116 changes: 116 additions & 0 deletions sources/odoo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
[options]


; --------------------
; change this ASAP!!!!
;---------------------
admin_passwd = somesuperstrongadminpasswdYOUNEEDTOCHANGEBEFORERUNNING

; set the default timezone for openerp interface
timezone = Europe/Paris

db_maxconn = 64

db_name = False
db_template = template1
dbfilter = .*

; set this to True if you have installed unaccent in your PostgreSQL
; and want to be able to search without accents
unaccent = True

; These options are really important and depend on the type of
; deployment you want to have so read the doc carefully and
; set these values accordingly
workers = 0
max_cron_threads = 2
limit_memory_hard = 2147483648
limit_memory_soft = 671088640
limit_request = 4096
limit_time_cpu = 120
limit_time_real = 180

; -----------------------------------------------------------------
; Below options are less critical but you are welcome to tweak them
; -----------------------------------------------------------------

csv_internal_sep = ,

debug_mode = False
demo = {}

email_from = False
import_partial =

list_db = True

log_handler = [':INFO']
log_level = info
logfile = None

login_message = False

logrotate = True

netrpc = False
netrpc_interface =
netrpc_port = 8070

osv_memory_age_limit = 1.0
osv_memory_count_limit = False

pg_path = None
pidfile = None

proxy_mode = False
reportgz = False

secure_cert_file = server.cert
secure_pkey_file = server.pkey

server_wide_modules = None

smtp_password = False
smtp_port = 25
smtp_server = localhost
smtp_ssl = False
smtp_user = False

static_http_document_root = None
static_http_enable = False
static_http_url_prefix = None

syslog = False

test_commit = False
test_enable = False
test_file = False
test_report_directory = False

translate_modules = ['all']
without_demo = False

xmlrpc = True
xmlrpc_interface =
xmlrpc_port = 8069
xmlrpcs = True
xmlrpcs_interface =
xmlrpcs_port = 8071

; DO NOT CHANGE THIS... It is setup accordingly to internal docker image layout
; READ the example run script to understand how it works

; do not change this
db_host = db
; if False then Odoo will fallback to 5432
db_port = False

; the PostgreSQL connection role Odoo will use to connect to its databases
db_user = pg
db_password = THIS-IS-NOT-USED-DONOT-CHANGE
addons_path = /opt/odoo/sources/odoo/addons,/opt/odoo/additional_addons

; additionnal parmameter for version 8+
data_dir = /opt/odoo/data
longpolling_port = 8072
proxy_mode = False
54 changes: 54 additions & 0 deletions sources/pip-req.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
argparse==1.2.1
Babel==1.3
cffi==0.8.6
cryptography==0.6.1
decorator==3.4.0
docutils==0.12
feedparser==5.1.3
gdata==2.0.18
Genshi==0.7
gevent==1.0.1
graphviz==0.4.2
greenlet==0.4.3
jcconv==0.2.3
Jinja2==2.7.3
lxml==3.4.1
Mako==1.0.0
MarkupSafe==0.23
#mercurial==3.0.1
mock==1.0.1
passlib==1.6.2
Pillow==2.5.3
pip==1.5.6
psutil==2.1.1
psycogreen==1.0
psycopg2==2.5.3
pycparser==2.10
pydot==1.0.2
pyjon.utils==0.7
pyOpenSSL==0.14
pyparsing==1.5.7
pyPdf==1.13
pyserial==2.7
python_dateutil==1.5
python_ldap==2.4.15
python_openid==2.2.5
python_stdnum==1.0
pytz==2014.10
pyusb==1.0.0b1
PyWebDAV==0.9.4.1
PyYAML==3.11
qrcode==5.0.1
reportlab==3.1.8
requests==2.3.0
setuptools==7.0
simplejson==3.5.3
six==1.7.3
suds==0.4
unittest2==0.5.1
vatnumber==1.2
vobject==0.6.6
Werkzeug==0.8.3
wheel==0.24.0
wsgiref==0.1.2
xlwt==0.7.5

0 comments on commit 93d045c

Please sign in to comment.