Skip to content

Commit d76f209

Browse files
committed
feat: merge APT/DEB layers to reduce image size
1 parent 71b1626 commit d76f209

File tree

2 files changed

+34
-40
lines changed

2 files changed

+34
-40
lines changed

18.0/Dockerfile

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ COPY --chown=odoo:root --chmod=660 ./extra_requirements.txt /odoo
2323
# Moved because there was a bug while installing `odoo-autodiscover`. There is
2424
# an accent in the contributor name
2525
ENV LANG=C.UTF-8 \
26-
LC_ALL=C.UTF-8
26+
LC_ALL=C.UTF-8 \
27+
PATH=/odoo/.venv/bin:$PATH \
28+
PYTHONPATH=/odoo/
2729

2830
# build and dev packages
2931
ENV BUILD_PACKAGE="\
@@ -45,17 +47,23 @@ ENV BUILD_PACKAGE="\
4547
# Default SHELL is ["/bin/sh", "-c"]
4648
SHELL ["/bin/sh", "-e", "-x", "-c"]
4749

50+
4851
# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf
4952
RUN /install/package_odoo.sh \
5053
&& /install/setup-pip.sh \
5154
&& /install/postgres.sh \
5255
&& /install/kwkhtml_client.sh \
5356
&& /install/kwkhtml_client_force_python3.sh \
54-
&& /install/dev_package.sh
55-
56-
# grab dockerize to generate template and
57-
# wait on postgres
58-
RUN /install/dockerize.sh
57+
# grab dockerize to generate template and \
58+
# wait on postgres \
59+
&& /install/dockerize.sh \
60+
&& /install/dev_package.sh \
61+
&& su odoo -c "umask 007 \
62+
&& python3 -m venv /odoo/.venv --system-site-packages \
63+
&& /odoo/.venv/bin/pip install -r /odoo/base_requirements.txt \
64+
&& /odoo/.venv/bin/pip install -r /odoo/extra_requirements.txt" \
65+
# Then purge build packages, to reduce layer size \
66+
&& /install/purge_dev_package_and_cache.sh
5967

6068
COPY --chown=odoo:root --chmod=660 ./src_requirements.txt /odoo
6169
COPY --chown=odoo:root --chmod=770 ./bin /odoo/odoo-bin
@@ -65,23 +73,9 @@ COPY --chown=odoo:root --chmod=770 ./start-entrypoint.d /odoo/start-entrypoint.d
6573
COPY --chown=odoo:root --chmod=660 ./MANIFEST.in /odoo
6674

6775

68-
VOLUME ["/data/odoo", "/var/log/odoo"]
6976
USER odoo
70-
RUN umask 007 \
71-
&& python3 -m venv /odoo/.venv --system-site-packages
72-
ENV PATH=/odoo/.venv/bin:$PATH
73-
ENV PYTHONPATH=/odoo/
7477
RUN echo "export PATH=$PATH" >> ~/.bashrc
7578

76-
RUN umask 007 \
77-
&& /odoo/.venv/bin/pip install -r /odoo/base_requirements.txt \
78-
&& /odoo/.venv/bin/pip install -r /odoo/extra_requirements.txt
79-
USER root
80-
RUN /install/purge_dev_package_and_cache.sh
81-
82-
USER odoo
83-
EXPOSE 8069 8072
84-
8579
ENV ODOO_VERSION=18.0 \
8680
PATH=/odoo/odoo-bin:/odoo/.local/bin:$PATH \
8781
LANG=C.UTF-8 \
@@ -99,5 +93,8 @@ ENV ODOO_VERSION=18.0 \
9993
ADDONS_PATH=/odoo/odoo/addons,/odoo/odoo/src/odoo/addons \
10094
ODOO_RC=/odoo/odoo.cfg
10195

96+
VOLUME ["/data/odoo", "/var/log/odoo"]
97+
EXPOSE 8069 8072
98+
10299
ENTRYPOINT ["docker-entrypoint.sh"]
103100
CMD ["odoo"]

19.0/Dockerfile

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ COPY --chown=odoo:root --chmod=660 ./extra_requirements.txt /odoo
2323
# Moved because there was a bug while installing `odoo-autodiscover`. There is
2424
# an accent in the contributor name
2525
ENV LANG=C.UTF-8 \
26-
LC_ALL=C.UTF-8
26+
LC_ALL=C.UTF-8 \
27+
PATH=/odoo/.venv/bin:$PATH \
28+
PYTHONPATH=/odoo/
2729

2830
# build and dev packages
2931
ENV BUILD_PACKAGE="\
@@ -45,17 +47,23 @@ ENV BUILD_PACKAGE="\
4547
# Default SHELL is ["/bin/sh", "-c"]
4648
SHELL ["/bin/sh", "-e", "-x", "-c"]
4749

50+
4851
# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf
4952
RUN /install/package_odoo.sh \
5053
&& /install/setup-pip.sh \
5154
&& /install/postgres.sh \
5255
&& /install/kwkhtml_client.sh \
5356
&& /install/kwkhtml_client_force_python3.sh \
54-
&& /install/dev_package.sh
55-
56-
# grab dockerize to generate template and
57-
# wait on postgres
58-
RUN /install/dockerize.sh
57+
# grab dockerize to generate template and \
58+
# wait on postgres \
59+
&& /install/dockerize.sh \
60+
&& /install/dev_package.sh \
61+
&& su odoo -c "umask 007 \
62+
&& python3 -m venv /odoo/.venv --system-site-packages \
63+
&& /odoo/.venv/bin/pip install -r /odoo/base_requirements.txt \
64+
&& /odoo/.venv/bin/pip install -r /odoo/extra_requirements.txt" \
65+
# Then purge build packages, to reduce layer size \
66+
&& /install/purge_dev_package_and_cache.sh
5967

6068
COPY --chown=odoo:root --chmod=660 ./src_requirements.txt /odoo
6169
COPY --chown=odoo:root --chmod=770 ./bin /odoo/odoo-bin
@@ -65,23 +73,9 @@ COPY --chown=odoo:root --chmod=770 ./start-entrypoint.d /odoo/start-entrypoint.d
6573
COPY --chown=odoo:root --chmod=660 ./MANIFEST.in /odoo
6674

6775

68-
VOLUME ["/data/odoo", "/var/log/odoo"]
6976
USER odoo
70-
RUN umask 007 \
71-
&& python3 -m venv /odoo/.venv --system-site-packages
72-
ENV PATH=/odoo/.venv/bin:$PATH
73-
ENV PYTHONPATH=/odoo/
7477
RUN echo "export PATH=$PATH" >> ~/.bashrc
7578

76-
RUN umask 007 \
77-
&& /odoo/.venv/bin/pip install -r /odoo/base_requirements.txt \
78-
&& /odoo/.venv/bin/pip install -r /odoo/extra_requirements.txt
79-
USER root
80-
RUN /install/purge_dev_package_and_cache.sh
81-
82-
USER odoo
83-
EXPOSE 8069 8072
84-
8579
ENV ODOO_VERSION=19.0 \
8680
PATH=/odoo/odoo-bin:/odoo/.local/bin:$PATH \
8781
LANG=C.UTF-8 \
@@ -99,5 +93,8 @@ ENV ODOO_VERSION=19.0 \
9993
ADDONS_PATH=/odoo/odoo/addons,/odoo/odoo/src/odoo/addons \
10094
ODOO_RC=/odoo/odoo.cfg
10195

96+
VOLUME ["/data/odoo", "/var/log/odoo"]
97+
EXPOSE 8069 8072
98+
10299
ENTRYPOINT ["docker-entrypoint.sh"]
103100
CMD ["odoo"]

0 commit comments

Comments
 (0)