forked from OCA/oca-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
167 lines (145 loc) · 6.06 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
ARG codename=focal
FROM ubuntu:$codename
ENV LANG C.UTF-8
USER root
# Basic dependencies
RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq --no-install-recommends \
ca-certificates \
curl \
gettext \
git \
gnupg \
lsb-release \
software-properties-common \
expect-dev
# Install wkhtml
RUN curl -sSL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.$(lsb_release -c -s)_amd64.deb -o /tmp/wkhtml.deb \
&& apt-get update -qq \
&& dpkg --force-depends -i /tmp/wkhtml.deb \
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq -f --no-install-recommends \
&& rm /tmp/wkhtml.deb
# Install nodejs dependencies
RUN curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_15.x `lsb_release -c -s` main" > /etc/apt/sources.list.d/nodesource.list \
&& apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq nodejs
# less is for odoo<12
RUN npm install -g rtlcss [email protected] less-plugin-clean-css
# Install postgresql client
RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -s -c`-pgdg main" > /etc/apt/sources.list.d/pgclient.list \
&& apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq postgresql-client-12
# Install Google Chrome for browser tests
ARG chrome_version=90.0.4430.93-1
RUN curl -sSL https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${chrome_version}_amd64.deb -o /tmp/chrome.deb \
&& apt-get -y install --no-install-recommends /tmp/chrome.deb \
&& rm /tmp/chrome.deb
RUN add-apt-repository -y ppa:deadsnakes/ppa
ARG python_version
# Install build dependencies for python libs commonly used by Odoo and OCA
RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq --no-install-recommends \
build-essential \
python$python_version-dev \
# we need python 3 for our helper scripts
python3 \
python3-venv \
# for psycopg
libpq-dev \
# for lxml
libxml2-dev \
libxslt1-dev \
libz-dev \
libxmlsec1-dev \
# for python-ldap
libldap2-dev \
libsasl2-dev \
# need libjpeg to build older pillow versions
libjpeg-dev \
# for pycups
libcups2-dev \
# for mysqlclient \
default-libmysqlclient-dev \
# some other build tools
swig \
libffi-dev \
pkg-config \
# We should install distutils if and only if it exists
&& apt-cache --generate pkgnames \
| grep --line-regexp --fixed-strings \
-e python$python_version-distutils \
| xargs apt install -y
# Install pipx, which we use to install other python tools.
ENV PIPX_BIN_DIR=/usr/local/bin
ENV PIPX_DEFAULT_PYTHON=/usr/bin/python3
RUN python3 -m venv /opt/pipx-venv \
&& /opt/pipx-venv/bin/pip install --no-cache-dir pipx \
&& ln -s /opt/pipx-venv/bin/pipx /usr/local/bin/
# We don't use the ubuntu virtualenv package because it unbundles pip dependencies
# in virtualenvs it create.
RUN pipx install --pip-args="--no-cache-dir" virtualenv
# We use manifestoo to check licenses, development status
RUN pipx install --pip-args="--no-cache-dir" "manifestoo>=0.3.1"
# Install the 'addons' helper script
# TODO: use manifestoo
RUN pipx install --pip-args="--no-cache-dir" acsoo==3.0.2
COPY bin/addons /usr/local/bin
# Install setuptools-odoo-get-requirements and setuptools-odoo-makedefault helper
# scripts.
RUN pipx install --pip-args="--no-cache-dir" "setuptools-odoo>=3.0.7"
# Make a virtualenv for Odoo so we isolate from system python dependencies and
# make sure addons we test declare all their python dependencies properly
ARG setuptools_constraint
RUN virtualenv -p python$python_version /opt/odoo-venv \
&& /opt/odoo-venv/bin/pip install "setuptools$setuptools_constraint" "pip>=21.3.1;python_version>='3.6'" \
&& /opt/odoo-venv/bin/pip list
ENV PATH=/opt/odoo-venv/bin:$PATH
ARG odoo_version
# Install Odoo requirements (use ADD for correct layer caching).
# We use requirements from OCB for easier maintenance of older versions.
# We use no-binary for psycopg2 because its binary wheels are sometimes broken
# and not very portable.
ADD https://raw.githubusercontent.com/OCA/OCB/$odoo_version/requirements.txt /tmp/ocb-requirements.txt
RUN pip install --no-cache-dir --no-binary psycopg2 -r /tmp/ocb-requirements.txt
# Install other test requirements.
# - coverage
# - websocket-client is required for Odoo browser tests
# - odoo-autodiscover required for python2
RUN pip install --no-cache-dir \
coverage \
websocket-client \
"odoo-autodiscover>=2 ; python_version<'3'"
# Install Odoo (use ADD for correct layer caching)
ARG odoo_org_repo=odoo/odoo
ADD https://api.github.com/repos/$odoo_org_repo/git/refs/heads/$odoo_version /tmp/odoo-version.json
RUN mkdir /tmp/getodoo \
&& (curl -sSL https://github.com/$odoo_org_repo/tarball/$odoo_version | tar -C /tmp/getodoo -xz) \
&& mv /tmp/getodoo/* /opt/odoo \
&& rmdir /tmp/getodoo
RUN pip install --no-cache-dir -e /opt/odoo \
&& pip list
# Make an empty odoo.cfg
RUN echo "[options]" > /etc/odoo.cfg
ENV ODOO_RC=/etc/odoo.cfg
ENV OPENERP_SERVER=/etc/odoo.cfg
COPY bin/* /usr/local/bin/
ENV ODOO_VERSION=$odoo_version
ENV PGHOST=postgres
ENV PGUSER=odoo
ENV PGPASSWORD=odoo
ENV PGDATABASE=odoo
# This PEP 503 index uses odoo addons from OCA and redirects the rest to PyPI,
# in effect hiding all non-OCA Odoo addons that are on PyPI.
ENV PIP_INDEX_URL=https://wheelhouse.odoo-community.org/oca-simple-and-pypi
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_NO_PYTHON_VERSION_WARNING=1
# Control addons discovery. INCLUDE and EXCLUDE are comma-separated list of
# addons to include (default: all) and exclude (default: none)
ENV ADDONS_DIR=.
ENV ADDONS_PATH=/opt/odoo/addons
ENV INCLUDE=
ENV EXCLUDE=
ENV OCA_GIT_USER_NAME=oca-ci