Skip to content

Commit

Permalink
feat: cache apt cache and pip cache via buildkit
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardotglobal authored Mar 4, 2024
1 parent bcbb9af commit b31451b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:

- name: Replace dockerfile with patched one
run: rm src/15.0.Dockerfile && mv Dockerfile src/15.0.Dockerfile

- name: Patch pip installer to allow caching
run: |
sed -i -E 's/^ _install_command = \["pip", "install", "--no-cache-dir", "-r"\]$/ _install_command = \["pip", "install", "-r"\]/' lib/doodbalib/installer.py
- name: Get date & commit sha
run: |
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# syntax = docker/dockerfile:1.2
FROM python:3.10-slim-bookworm AS base

EXPOSE 8069 8072
Expand Down Expand Up @@ -228,14 +229,18 @@ ONBUILD ENV ADMIN_PASSWORD="$ADMIN_PASSWORD" \
ONBUILD ARG LOCAL_CUSTOM_DIR=./custom
ONBUILD COPY --chown=root:odoo $LOCAL_CUSTOM_DIR /opt/odoo/custom

# Do not delete apt cache
ONBUILD RUN rm -f /etc/apt/apt.conf.d/docker-clean

# https://docs.python.org/3/library/logging.html#levels
ONBUILD ARG LOG_LEVEL=INFO
ONBUILD RUN [ -d ~root/.ssh ] && rm -r ~root/.ssh; \
mkdir -p /opt/odoo/custom/ssh \
&& ln -s /opt/odoo/custom/ssh ~root/.ssh \
&& chmod -R u=rwX,go= /opt/odoo/custom/ssh \
&& sync

ONBUILD ARG DB_VERSION=latest
ONBUILD RUN /opt/odoo/common/build && sync
ONBUILD RUN --mount=type=cache,target=/var/cache/apt ---mount=type=cache,target=/root/.cache /opt/odoo/common/build && sync
ONBUILD VOLUME ["/var/lib/odoo"]
ONBUILD USER odoo

0 comments on commit b31451b

Please sign in to comment.