forked from iterativo-git/dockerdoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
316 lines (276 loc) · 9.8 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
FROM python:3.8-slim-buster as base
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
USER root
# Library versions
ARG WKHTMLTOX_VERSION
ENV WKHTMLTOX_VERSION ${WKHTMLTOX_VERSION:-"0.12.5"}
ARG WKHTMLTOPDF_CHECKSUM
ENV WKHTMLTOPDF_CHECKSUM ${WKHTMLTOPDF_CHECKSUM:-"ea8277df4297afc507c61122f3c349af142f31e5"}
# Use noninteractive to get rid of apt-utils message
ENV DEBIAN_FRONTEND=noninteractive
# Install odoo deps
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends \
ca-certificates \
curl \
chromium \
dirmngr \
git-core \
gnupg \
htop \
ffmpeg \
fonts-liberation2 \
fonts-noto-cjk \
locales \
node-less \
npm \
python3-num2words \
python3-pdfminer \
python3-pip \
python3-phonenumbers \
python3-pyldap \
python3-qrcode \
python3-renderpm \
python3-setuptools \
python3-slugify \
python3-vobject \
python3-watchdog \
python3-xlrd \
python3-xlwt \
nano \
ssh \
# Add sudo support for the non-root user & unzip for CI
sudo \
unzip \
vim \
zip \
xz-utils \
&& \
if [ "$(uname -m)" = "aarch64" ]; then \
curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_arm64.deb \
; else \
curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/${WKHTMLTOX_VERSION}/wkhtmltox_${WKHTMLTOX_VERSION}-1.buster_amd64.deb \
&& echo "${WKHTMLTOPDF_CHECKSUM} wkhtmltox.deb" | sha1sum -c - \
; fi \
&& apt-get install -y --no-install-recommends ./wkhtmltox.deb \
&& apt-get autopurge -yqq \
&& rm -rf /var/lib/apt/lists/* wkhtmltox.deb /tmp/*
# install latest postgresql-client
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends \
lsb-release \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& GNUPGHOME="$(mktemp -d)" \
&& export GNUPGHOME \
&& repokey='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8' \
&& gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${repokey}" \
&& gpg --batch --armor --export "${repokey}" > /etc/apt/trusted.gpg.d/pgdg.gpg.asc \
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" \
&& apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends postgresql-client libpq-dev \
&& rm -f /etc/apt/sources.list.d/pgdg.list \
&& rm -rf /var/lib/apt/lists/*
# Install rtlcss (on Debian buster)
RUN npm install -g rtlcss \
&& rm -Rf ~/.npm /tmp/*
FROM base as builder
# Install hard & soft build dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils dialog \
apt-transport-https \
build-essential \
libfreetype6-dev \
libfribidi-dev \
libghc-zlib-dev \
libharfbuzz-dev \
libjpeg-dev \
libgeoip-dev \
libmaxminddb-dev \
liblcms2-dev \
libldap2-dev \
libopenjp2-7-dev \
libssl-dev \
libsasl2-dev \
libtiff5-dev \
libxml2-dev \
libxslt1-dev \
libwebp-dev \
tcl-dev \
tk-dev \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/* /tmp/*
# Install Odoo source code and install it as a package inside the container with additional tools
ENV ODOO_VERSION ${ODOO_VERSION:-14.0}
RUN pip3 install --prefix=/usr/local --no-cache-dir --upgrade --requirement https://raw.githubusercontent.com/odoo/odoo/${ODOO_VERSION}/requirements.txt \
&& pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade \
'websocket-client~=0.56' \
astor \
black \
pylint-odoo \
flake8 \
pydevd-odoo \
psycogreen \
python-magic \
python-stdnum \
click-odoo-contrib \
git-aggregator \
inotify \
python-json-logger \
wdb \
redis \
reportlab \
&& apt-get autopurge -yqq \
&& rm -rf /var/lib/apt/lists/* /tmp/*
RUN git clone --depth 100 -b ${ODOO_VERSION} https://github.com/odoo/odoo.git /opt/odoo \
&& pip3 install --editable /opt/odoo \
&& pip3 -qq install --prefix=/usr/local --no-cache-dir --upgrade \
gevent==20.12.1 \
greenlet==0.4.17 \
Werkzeug==0.15.6 \
# debugpy has python2 libraries which can't be compiled with python3
debugpy \
&& rm -rf /var/lib/apt/lists/* /tmp/*
FROM base as production
# PIP auto-install requirements.txt (change value to "1" to auto-install)
ENV PIP_AUTO_INSTALL=${PIP_AUTO_INSTALL:-"0"}
# Run tests for all the modules in the custom addons
ENV RUN_TESTS=${RUN_TESTS:-"0"}
# Run tests for all installed modules
ENV WITHOUT_TEST_TAGS=${WITHOUT_TEST_TAGS:-"0"}
# Upgrade all databases visible to this Odoo instance
ENV UPGRADE_ODOO=${UPGRADE_ODOO:-"0"}
# Create app user
ENV ODOO_USER odoo
ENV ODOO_BASEPATH ${ODOO_BASEPATH:-/opt/odoo}
ARG APP_UID
ENV APP_UID ${APP_UID:-1000}
ARG APP_GID
ENV APP_GID ${APP_UID:-1000}
RUN addgroup --system --gid ${APP_GID} ${ODOO_USER} \
&& adduser --system --uid ${APP_UID} --ingroup ${ODOO_USER} --home ${ODOO_BASEPATH} --disabled-login --shell /sbin/nologin ${ODOO_USER} \
&& echo ${ODOO_USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${ODOO_USER}\
&& chmod 0440 /etc/sudoers.d/${ODOO_USER}
# Odoo Configuration file variables and defaults
ARG ADMIN_PASSWORD
ARG PGHOST
ARG PGUSER
ARG PGPORT
ARG PGPASSWORD
ARG DB_TEMPLATE
ARG HTTP_INTERFACE
ARG HTTP_PORT
ARG DBFILTER
ARG DBNAME
ARG SERVER_WIDE_MODULES
ENV \
ADMIN_PASSWORD=${ADMIN_PASSWORD:-my-weak-password} \
ODOO_DATA_DIR=${ODOO_DATA_DIR:-/var/lib/odoo/data} \
DB_PORT_5432_TCP_ADDR=${PGHOST:-db} \
DB_MAXCONN=${DB_MAXCONN:-64} \
DB_ENV_POSTGRES_PASSWORD=${PGPASSWORD:-odoo} \
DB_PORT_5432_TCP_PORT=${PGPORT:-5432} \
DB_SSLMODE=${DB_SSLMODE:-prefer} \
DB_TEMPLATE=${DB_TEMPLATE:-template1} \
DB_ENV_POSTGRES_USER=${PGUSER:-odoo} \
DBFILTER=${DBFILTER:-.*} \
DBNAME=${DBNAME} \
HTTP_INTERFACE=${HTTP_INTERFACE:-0.0.0.0} \
HTTP_PORT=${HTTP_PORT:-8069} \
LIMIT_REQUEST=${LIMIT_REQUEST:-8196} \
LIMIT_MEMORY_HARD=${LIMIT_MEMORY_HARD:-2684354560} \
LIMIT_MEMORY_SOFT=${LIMIT_MEMORY_SOFT:-2147483648} \
LIMIT_TIME_CPU=${LIMIT_TIME_CPU:-60} \
LIMIT_TIME_REAL=${LIMIT_TIME_REAL:-120} \
LIMIT_TIME_REAL_CRON=${LIMIT_TIME_REAL_CRON:-0} \
LIST_DB=${LIST_DB:-True} \
LOG_DB=${LOG_DB:-False} \
LOG_DB_LEVEL=${LOG_DB_LEVEL:-warning} \
LOGFILE=${LOGFILE:-None} \
LOG_HANDLER=${LOG_HANDLER:-:INFO} \
LOG_LEVEL=${LOG_LEVEL:-info} \
MAX_CRON_THREADS=${MAX_CRON_THREADS:-2} \
PROXY_MODE=${PROXY_MODE:-False} \
SERVER_WIDE_MODULES=${SERVER_WIDE_MODULES:-base,web} \
SMTP_PASSWORD=${SMTP_PASSWORD:-False} \
SMTP_PORT=${SMTP_PORT:-25} \
SMTP_SERVER=${SMTP_SERVER:-localhost} \
SMTP_SSL=${SMTP_SSL:-False} \
SMTP_USER=${SMTP_USER:-False} \
TEST_ENABLE=${TEST_ENABLE:-False} \
UNACCENT=${UNACCENT:-False} \
WITHOUT_DEMO=${WITHOUT_DEMO:-False} \
WORKERS=${WORKERS:-0}
# camptocamp variables (to be used on cloud deployments)
# Sessions in Redis
ARG ODOO_SESSION_REDIS
ARG ODOO_SESSION_REDIS_HOST
ARG ODOO_SESSION_REDIS_PASSWORD
ARG ODOO_SESSION_REDIS_PREFIX
# JSON logging
ARG ODOO_LOGGING_JSON
# Attachments in the Object Storage S3
ARG AWS_HOST
ARG AWS_REGION
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_BUCKETNAME
# Metrics (Statsd/Prometheus for Grafana)
ARG ODOO_STATSD
ARG STATSD_CUSTOMER
ARG STATSD_ENVIRONMENT
ARG STATSD_HOST
ARG STATSD_PORT
# Automatic Configuration Startup checks
ARG ODOO_CLOUD_PLATFORM_UNSAFE
ARG RUNNING_ENV
ENV \
ODOO_SESSION_REDIS=${ODOO_SESSION_REDIS:-0} \
ODOO_SESSION_REDIS_HOST=${ODOO_SESSION_REDIS_HOST} \
ODOO_SESSION_REDIS_PASSWORD=${ODOO_SESSION_REDIS_PASSWORD} \
ODOO_SESSION_REDIS_PREFIX=${ODOO_SESSION_REDIS_PREFIX} \
ODOO_LOGGING_JSON=${ODOO_LOGGING_JSON:-0} \
AWS_HOST=${AWS_HOST} \
AWS_REGION=${AWS_REGION} \
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
AWS_BUCKETNAME=${AWS_BUCKETNAME} \
ODOO_STATSD=${ODOO_STATSD} \
STATSD_CUSTOMER=${STATSD_CUSTOMER} \
STATSD_ENVIRONMENT=${STATSD_ENVIRONMENT} \
STATSD_HOST=${STATSD_HOST} \
STATSD_PORT=${STATSD_PORT} \
RUNNING_ENV=${RUNNING_ENV}
# Define all needed directories
ENV ODOO_RC ${ODOO_RC:-/etc/odoo/odoo.conf}
ENV ODOO_DATA_DIR ${ODOO_DATA_DIR:-/var/lib/odoo/data}
ENV ODOO_LOGS_DIR ${ODOO_LOGS_DIR:-/var/lib/odoo/logs}
ENV ODOO_EXTRA_ADDONS ${ODOO_EXTRA_ADDONS:-/mnt/extra-addons}
ENV ODOO_ADDONS_BASEPATH ${ODOO_BASEPATH}/addons
ENV ODOO_CMD ${ODOO_BASEPATH}/odoo-bin
RUN mkdir -p ${ODOO_DATA_DIR} ${ODOO_LOGS_DIR} ${ODOO_EXTRA_ADDONS} /etc/odoo/
# Own folders //-- docker-compose creates named volumes owned by root:root. Issue: https://github.com/docker/compose/issues/3270
RUN chown -R ${ODOO_USER}:${ODOO_USER} ${ODOO_DATA_DIR} ${ODOO_LOGS_DIR} ${ODOO_EXTRA_ADDONS} ${ODOO_BASEPATH} /etc/odoo
VOLUME ["${ODOO_DATA_DIR}", "${ODOO_LOGS_DIR}", "${ODOO_EXTRA_ADDONS}"]
ARG EXTRA_ADDONS_PATHS
ENV EXTRA_ADDONS_PATHS ${EXTRA_ADDONS_PATHS}
ARG EXTRA_MODULES
ENV EXTRA_MODULES ${EXTRA_MODULES}
COPY --chown=${ODOO_USER}:${ODOO_USER} --from=builder /usr/local /usr/local
COPY --chown=${ODOO_USER}:${ODOO_USER} --from=builder /opt/odoo ${ODOO_BASEPATH}
# Copy from build env
COPY --chown=${ODOO_USER}:${ODOO_USER} ./resources/entrypoint.sh /
COPY --chown=${ODOO_USER}:${ODOO_USER} ./resources/getaddons.py /
# This is needed to fully build with modules and python requirements
# Copy custom modules from the custom folder, if any.
ARG HOST_CUSTOM_ADDONS
ENV HOST_CUSTOM_ADDONS ${HOST_CUSTOM_ADDONS:-./custom}
COPY --chown=${ODOO_USER}:${ODOO_USER} ${HOST_CUSTOM_ADDONS} ${ODOO_EXTRA_ADDONS}
RUN chmod u+x /entrypoint.sh
EXPOSE 8069 8071 8072
# Docker healthcheck command
HEALTHCHECK CMD curl --fail http://127.0.0.1:8069/web_editor/static/src/xml/ace.xml || exit 1
ENTRYPOINT ["/entrypoint.sh"]
USER ${ODOO_USER}
CMD ["/opt/odoo/odoo-bin"]