Skip to content

Commit 39e4c45

Browse files
authored
feat: impove image size (#371)
* feat: impove image size
1 parent 0467601 commit 39e4c45

File tree

5 files changed

+111
-108
lines changed

5 files changed

+111
-108
lines changed

14.0/Dockerfile

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
FROM python:3.9-slim-trixie
22
ARG UID=999
3-
ARG GID=999
3+
ARG GID=0
44
# create the working directory and a place to set the logs (if wanted)
5-
RUN mkdir -p /odoo /var/log/odoo
5+
RUN mkdir -p /odoo /var/log/odoo /odoo/.venv
66

7-
COPY ./install /install
8-
COPY ./base_requirements.txt /odoo
9-
COPY ./extra_requirements.txt /odoo
10-
COPY ./test_requirements.txt /odoo
7+
8+
RUN adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
9+
&& touch /odoo/odoo.cfg \
10+
&& touch /odoo/.bashrc \
11+
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
12+
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
13+
&& chown -R odoo:root /var/log/odoo
14+
15+
COPY --chown=odoo:root --chmod=770 ./install /install
16+
COPY --chown=odoo:root --chmod=660 ./base_requirements.txt /odoo
17+
COPY --chown=odoo:root --chmod=660 ./extra_requirements.txt /odoo
1118

1219
# Moved because there was a bug while installing `odoo-autodiscover`. There is
1320
# an accent in the contributor name
@@ -45,36 +52,29 @@ RUN set -x; \
4552
# wait on postgres
4653
RUN /install/dockerize.sh
4754

48-
COPY ./src_requirements.txt /odoo
49-
COPY ./bin /odoo/odoo-bin
50-
COPY ./templates /templates
51-
COPY ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
52-
COPY ./start-entrypoint.d /odoo/start-entrypoint.d
53-
COPY ./MANIFEST.in /odoo
55+
COPY --chown=odoo:root --chmod=660 ./src_requirements.txt /odoo
56+
COPY --chown=odoo:root --chmod=770 ./bin /odoo/odoo-bin
57+
COPY --chown=odoo:root --chmod=660 ./templates /templates
58+
COPY --chown=odoo:root --chmod=770 ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
59+
COPY --chown=odoo:root --chmod=770 ./start-entrypoint.d /odoo/start-entrypoint.d
60+
COPY --chown=odoo:root --chmod=770 ./MANIFEST.in /odoo
61+
5462

55-
RUN groupadd -g $GID odoo \
56-
&& adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
57-
&& touch /odoo/odoo.cfg \
58-
&& touch /odoo/.bashrc \
59-
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
60-
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
61-
&& chown -R odoo:root /var/log/odoo
6263

6364
VOLUME ["/data/odoo", "/var/log/odoo"]
6465
USER odoo
66+
RUN chmod -R 770 /odoo/.venv
6567
RUN python3 -m venv /odoo/.venv --system-site-packages
6668
ENV PATH=/odoo/.venv/bin:$PATH
6769
ENV PYTHONPATH=/odoo/
6870
RUN echo "export PATH=$PATH" >> ~/.bashrc
6971

7072
RUN /odoo/.venv/bin/pip install -r /odoo/base_requirements.txt
7173
RUN /odoo/.venv/bin/pip install -r /odoo/extra_requirements.txt
72-
RUN /odoo/.venv/bin/pip install -r /odoo/test_requirements.txt
7374
USER root
7475
RUN set -x; \
7576
sh -c /install/purge_dev_package_and_cache.sh
76-
RUN chgrp -R 0 /odoo && \
77-
chmod -R g=u /odoo
77+
7878
USER odoo
7979
EXPOSE 8069 8072
8080

15.0/Dockerfile

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
FROM python:3.12-slim-trixie
22
ARG UID=999
3-
ARG GID=999
3+
ARG GID=0
44
# create the working directory and a place to set the logs (if wanted)
5-
RUN mkdir -p /odoo /var/log/odoo
5+
RUN mkdir -p /odoo /var/log/odoo /odoo/.venv
66

7-
COPY ./install /install
8-
COPY ./base_requirements.txt /odoo
9-
COPY ./extra_requirements.txt /odoo
10-
COPY ./test_requirements.txt /odoo
7+
8+
RUN adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
9+
&& touch /odoo/odoo.cfg \
10+
&& touch /odoo/.bashrc \
11+
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
12+
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
13+
&& chown -R odoo:root /var/log/odoo
14+
15+
COPY --chown=odoo:root --chmod=770 ./install /install
16+
COPY --chown=odoo:root --chmod=660 ./base_requirements.txt /odoo
17+
COPY --chown=odoo:root --chmod=660 ./extra_requirements.txt /odoo
1118

1219
# Moved because there was a bug while installing `odoo-autodiscover`. There is
1320
# an accent in the contributor name
@@ -45,36 +52,29 @@ RUN set -x; \
4552
# wait on postgres
4653
RUN /install/dockerize.sh
4754

48-
COPY ./src_requirements.txt /odoo
49-
COPY ./bin /odoo/odoo-bin
50-
COPY ./templates /templates
51-
COPY ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
52-
COPY ./start-entrypoint.d /odoo/start-entrypoint.d
53-
COPY ./MANIFEST.in /odoo
55+
COPY --chown=odoo:root --chmod=660 ./src_requirements.txt /odoo
56+
COPY --chown=odoo:root --chmod=770 ./bin /odoo/odoo-bin
57+
COPY --chown=odoo:root --chmod=660 ./templates /templates
58+
COPY --chown=odoo:root --chmod=770 ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
59+
COPY --chown=odoo:root --chmod=770 ./start-entrypoint.d /odoo/start-entrypoint.d
60+
COPY --chown=odoo:root --chmod=770 ./MANIFEST.in /odoo
61+
5462

55-
RUN groupadd -g $GID odoo \
56-
&& adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
57-
&& touch /odoo/odoo.cfg \
58-
&& touch /odoo/.bashrc \
59-
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
60-
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
61-
&& chown -R odoo:root /var/log/odoo
6263

6364
VOLUME ["/data/odoo", "/var/log/odoo"]
6465
USER odoo
65-
RUN python3 -m venv /odoo/.venv --system-site-packages
66+
RUN chmod -R 770 /odoo/.venv
67+
RUN python3 -m venv /odoo/.venv --system-site-packages
6668
ENV PATH=/odoo/.venv/bin:$PATH
6769
ENV PYTHONPATH=/odoo/
6870
RUN echo "export PATH=$PATH" >> ~/.bashrc
6971

7072
RUN /odoo/.venv/bin/pip install -r /odoo/base_requirements.txt
7173
RUN /odoo/.venv/bin/pip install -r /odoo/extra_requirements.txt
72-
RUN /odoo/.venv/bin/pip install -r /odoo/test_requirements.txt
7374
USER root
7475
RUN set -x; \
7576
sh -c /install/purge_dev_package_and_cache.sh
76-
RUN chgrp -R 0 /odoo && \
77-
chmod -R g=u /odoo
77+
7878
USER odoo
7979
EXPOSE 8069 8072
8080

16.0/Dockerfile

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
FROM python:3.12-slim-trixie
22
ARG UID=999
3-
ARG GID=999
3+
ARG GID=0
44
# create the working directory and a place to set the logs (if wanted)
5-
RUN mkdir -p /odoo /var/log/odoo
5+
RUN mkdir -p /odoo /var/log/odoo /odoo/.venv
66

7-
COPY ./install /install
8-
COPY ./base_requirements.txt /odoo
9-
COPY ./extra_requirements.txt /odoo
7+
8+
RUN adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
9+
&& touch /odoo/odoo.cfg \
10+
&& touch /odoo/.bashrc \
11+
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
12+
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
13+
&& chown -R odoo:root /var/log/odoo
14+
15+
COPY --chown=odoo:root --chmod=770 ./install /install
16+
COPY --chown=odoo:root --chmod=660 ./base_requirements.txt /odoo
17+
COPY --chown=odoo:root --chmod=660 ./extra_requirements.txt /odoo
1018

1119
# Moved because there was a bug while installing `odoo-autodiscover`. There is
1220
# an accent in the contributor name
@@ -44,23 +52,17 @@ RUN set -x; \
4452
# wait on postgres
4553
RUN /install/dockerize.sh
4654

47-
COPY ./src_requirements.txt /odoo
48-
COPY ./bin /odoo/odoo-bin
49-
COPY ./templates /templates
50-
COPY ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
51-
COPY ./start-entrypoint.d /odoo/start-entrypoint.d
52-
COPY ./MANIFEST.in /odoo
55+
COPY --chown=odoo:root --chmod=660 ./src_requirements.txt /odoo
56+
COPY --chown=odoo:root --chmod=770 ./bin /odoo/odoo-bin
57+
COPY --chown=odoo:root --chmod=660 ./templates /templates
58+
COPY --chown=odoo:root --chmod=770 ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
59+
COPY --chown=odoo:root --chmod=770 ./start-entrypoint.d /odoo/start-entrypoint.d
60+
COPY --chown=odoo:root --chmod=770 ./MANIFEST.in /odoo
5361

54-
RUN groupadd -g $GID odoo \
55-
&& adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
56-
&& touch /odoo/odoo.cfg \
57-
&& touch /odoo/.bashrc \
58-
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
59-
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
60-
&& chown -R odoo:root /var/log/odoo
6162

6263
VOLUME ["/data/odoo", "/var/log/odoo"]
6364
USER odoo
65+
RUN chmod -R 770 /odoo/.venv
6466
RUN python3 -m venv /odoo/.venv --system-site-packages
6567
ENV PATH=/odoo/.venv/bin:$PATH
6668
ENV PYTHONPATH=/odoo/
@@ -71,8 +73,7 @@ RUN /odoo/.venv/bin/pip install -r /odoo/extra_requirements.txt
7173
USER root
7274
RUN set -x; \
7375
sh -c /install/purge_dev_package_and_cache.sh
74-
RUN chgrp -R 0 /odoo && \
75-
chmod -R g=u /odoo
76+
7677
USER odoo
7778
EXPOSE 8069 8072
7879

17.0/Dockerfile

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
FROM python:3.12-slim-trixie
22
ARG UID=999
3-
ARG GID=999
3+
ARG GID=0
44
# create the working directory and a place to set the logs (if wanted)
5-
RUN mkdir -p /odoo /var/log/odoo
5+
RUN mkdir -p /odoo /var/log/odoo /odoo/.venv
66

7-
COPY ./install /install
8-
COPY ./base_requirements.txt /odoo
9-
COPY ./extra_requirements.txt /odoo
10-
COPY ./test_requirements.txt /odoo
7+
8+
RUN adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
9+
&& touch /odoo/odoo.cfg \
10+
&& touch /odoo/.bashrc \
11+
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
12+
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
13+
&& chown -R odoo:root /var/log/odoo
14+
15+
COPY --chown=odoo:root --chmod=770 ./install /install
16+
COPY --chown=odoo:root --chmod=660 ./base_requirements.txt /odoo
17+
COPY --chown=odoo:root --chmod=660 ./extra_requirements.txt /odoo
1118

1219
# Moved because there was a bug while installing `odoo-autodiscover`. There is
1320
# an accent in the contributor name
@@ -46,36 +53,29 @@ RUN set -x; \
4653
# wait on postgres
4754
RUN /install/dockerize.sh
4855

49-
COPY ./src_requirements.txt /odoo
50-
COPY ./bin /odoo/odoo-bin
51-
COPY ./templates /templates
52-
COPY ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
53-
COPY ./start-entrypoint.d /odoo/start-entrypoint.d
54-
COPY ./MANIFEST.in /odoo
56+
COPY --chown=odoo:root --chmod=660 ./src_requirements.txt /odoo
57+
COPY --chown=odoo:root --chmod=770 ./bin /odoo/odoo-bin
58+
COPY --chown=odoo:root --chmod=660 ./templates /templates
59+
COPY --chown=odoo:root --chmod=770 ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
60+
COPY --chown=odoo:root --chmod=770 ./start-entrypoint.d /odoo/start-entrypoint.d
61+
COPY --chown=odoo:root --chmod=770 ./MANIFEST.in /odoo
62+
5563

56-
RUN groupadd -g $GID odoo \
57-
&& adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
58-
&& touch /odoo/odoo.cfg \
59-
&& touch /odoo/.bashrc \
60-
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
61-
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
62-
&& chown -R odoo:root /var/log/odoo
6364

6465
VOLUME ["/data/odoo", "/var/log/odoo"]
6566
USER odoo
67+
RUN chmod -R 770 /odoo/.venv
6668
RUN python3 -m venv /odoo/.venv --system-site-packages
6769
ENV PATH=/odoo/.venv/bin:$PATH
6870
ENV PYTHONPATH=/odoo/
6971
RUN echo "export PATH=$PATH" >> ~/.bashrc
7072

7173
RUN /odoo/.venv/bin/pip install -r /odoo/base_requirements.txt
7274
RUN /odoo/.venv/bin/pip install -r /odoo/extra_requirements.txt
73-
RUN /odoo/.venv/bin/pip install -r /odoo/test_requirements.txt
7475
USER root
7576
RUN set -x; \
7677
sh -c /install/purge_dev_package_and_cache.sh
77-
RUN chgrp -R 0 /odoo && \
78-
chmod -R g=u /odoo
78+
7979
USER odoo
8080
EXPOSE 8069 8072
8181

18.0/Dockerfile

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
FROM python:3.12-slim-trixie
22
ARG UID=999
3-
ARG GID=999
3+
ARG GID=0
44
# create the working directory and a place to set the logs (if wanted)
5-
RUN mkdir -p /odoo /var/log/odoo
5+
RUN mkdir -p /odoo /var/log/odoo /odoo/.venv
66

7-
COPY ./install /install
8-
COPY ./base_requirements.txt /odoo
9-
COPY ./extra_requirements.txt /odoo
7+
8+
RUN adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
9+
&& touch /odoo/odoo.cfg \
10+
&& touch /odoo/.bashrc \
11+
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
12+
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
13+
&& chown -R odoo:root /var/log/odoo
14+
15+
COPY --chown=odoo:root --chmod=770 ./install /install
16+
COPY --chown=odoo:root --chmod=660 ./base_requirements.txt /odoo
17+
COPY --chown=odoo:root --chmod=660 ./extra_requirements.txt /odoo
1018

1119
# Moved because there was a bug while installing `odoo-autodiscover`. There is
1220
# an accent in the contributor name
@@ -44,24 +52,19 @@ RUN set -x; \
4452
# wait on postgres
4553
RUN /install/dockerize.sh
4654

47-
COPY ./src_requirements.txt /odoo
48-
COPY ./bin /odoo/odoo-bin
49-
COPY ./templates /templates
50-
COPY ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
51-
COPY ./start-entrypoint.d /odoo/start-entrypoint.d
52-
COPY ./MANIFEST.in /odoo
55+
COPY --chown=odoo:root --chmod=660 ./src_requirements.txt /odoo
56+
COPY --chown=odoo:root --chmod=770 ./bin /odoo/odoo-bin
57+
COPY --chown=odoo:root --chmod=660 ./templates /templates
58+
COPY --chown=odoo:root --chmod=770 ./before-migrate-entrypoint.d /odoo/before-migrate-entrypoint.d
59+
COPY --chown=odoo:root --chmod=770 ./start-entrypoint.d /odoo/start-entrypoint.d
60+
COPY --chown=odoo:root --chmod=770 ./MANIFEST.in /odoo
61+
5362

54-
RUN groupadd -g $GID odoo \
55-
&& adduser --disabled-password -u $UID --gid $GID --gecos '' odoo \
56-
&& touch /odoo/odoo.cfg \
57-
&& touch /odoo/.bashrc \
58-
&& mkdir -p /odoo/data/odoo/{addons,filestore,sessions} \
59-
&& chown -R odoo:root /odoo && usermod odoo --home /odoo \
60-
&& chown -R odoo:root /var/log/odoo
6163

6264
VOLUME ["/data/odoo", "/var/log/odoo"]
6365
USER odoo
64-
RUN python3 -m venv /odoo/.venv --system-site-packages
66+
RUN chmod -R 770 /odoo/.venv
67+
RUN python3 -m venv /odoo/.venv --system-site-packages
6568
ENV PATH=/odoo/.venv/bin:$PATH
6669
ENV PYTHONPATH=/odoo/
6770
RUN echo "export PATH=$PATH" >> ~/.bashrc
@@ -71,8 +74,7 @@ RUN /odoo/.venv/bin/pip install -r /odoo/extra_requirements.txt
7174
USER root
7275
RUN set -x; \
7376
sh -c /install/purge_dev_package_and_cache.sh
74-
RUN chgrp -R 0 /odoo && \
75-
chmod -R g=u /odoo
77+
7678
USER odoo
7779
EXPOSE 8069 8072
7880

0 commit comments

Comments
 (0)