Skip to content

Commit

Permalink
images for Odoo 12, 13, 14, 15 and 16
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalyi committed Aug 15, 2023
1 parent b2cead8 commit 706f60e
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ jobs:
strategy:
matrix:
include:
- ODOOVERSION: "12.0"
- ODOOVERSION: "13.0"
- ODOOVERSION: "14.0"
- ODOOVERSION: "15.0"
- ODOOVERSION: "16.0"

steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
Expand Down
26 changes: 26 additions & 0 deletions 12.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.10.12-alpine3.18

RUN apk fix && \
apk --no-cache --update add git git-lfs gpg less openssh patch bash && \
git lfs install

# we cannot use a more recent version for now
# see https://github.com/yaml/pyyaml/issues/724
# note that we install ak and git-aggregator to be able to do ak-build
# later in a builder image based on this image and ensure odoo/src
# is converged to the proper revision with the proper merges
RUN pip install PyYaml==5.3.1
RUN pip install git+https://github.com/akretion/ak

COPY repos.yml /root/.config/git-autoshare/repos.yml
RUN pip install git-autoshare git-aggregator
COPY bin/* /usr/local/bin/
COPY install/* /install/

# pre-fetch the git-autoshare cache with the bare minimum:
ADD https://api.github.com/repos/odoo/odoo/git/refs/heads/12.0 version.json
RUN mkdir -p /root/.cache/git-autoshare/github.com/odoo && \
cd /root/.cache/git-autoshare/github.com/odoo && \
/usr/bin/git init --bare && \
/usr/bin/git fetch https://github.com/OCA/OCB.git refs/heads/12.0:refs/git-autoshare/oca/heads/12.0 --shallow-since=2018-10-01 && \
/usr/bin/git fetch https://github.com/odoo/odoo.git refs/heads/12.0:refs/git-autoshare/odoo/heads/12.0 --shallow-since=2018-10-01
26 changes: 26 additions & 0 deletions 13.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.10.12-alpine3.18

RUN apk fix && \
apk --no-cache --update add git git-lfs gpg less openssh patch bash && \
git lfs install

# we cannot use a more recent version for now
# see https://github.com/yaml/pyyaml/issues/724
# note that we install ak and git-aggregator to be able to do ak-build
# later in a builder image based on this image and ensure odoo/src
# is converged to the proper revision with the proper merges
RUN pip install PyYaml==5.3.1
RUN pip install git+https://github.com/akretion/ak

COPY repos.yml /root/.config/git-autoshare/repos.yml
RUN pip install git-autoshare git-aggregator
COPY bin/* /usr/local/bin/
COPY install/* /install/

# pre-fetch the git-autoshare cache with the bare minimum:
ADD https://api.github.com/repos/odoo/odoo/git/refs/heads/13.0 version.json
RUN mkdir -p /root/.cache/git-autoshare/github.com/odoo && \
cd /root/.cache/git-autoshare/github.com/odoo && \
/usr/bin/git init --bare && \
/usr/bin/git fetch https://github.com/OCA/OCB.git refs/heads/13.0:refs/git-autoshare/oca/heads/13.0 --shallow-since=2019-10-01 && \
/usr/bin/git fetch https://github.com/odoo/odoo.git refs/heads/13.0:refs/git-autoshare/odoo/heads/13.0 --shallow-since=2019-10-01
4 changes: 2 additions & 2 deletions 14.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ ADD https://api.github.com/repos/odoo/odoo/git/refs/heads/14.0 version.json
RUN mkdir -p /root/.cache/git-autoshare/github.com/odoo && \
cd /root/.cache/git-autoshare/github.com/odoo && \
/usr/bin/git init --bare && \
/usr/bin/git fetch https://github.com/OCA/OCB.git refs/heads/14.0:refs/git-autoshare/oca/heads/14.0 --shallow-since=2021-10-01 && \
/usr/bin/git fetch https://github.com/odoo/odoo.git refs/heads/14.0:refs/git-autoshare/odoo/heads/14.0 --shallow-since=2021-10-01
/usr/bin/git fetch https://github.com/OCA/OCB.git refs/heads/14.0:refs/git-autoshare/oca/heads/14.0 --shallow-since=2020-10-01 && \
/usr/bin/git fetch https://github.com/odoo/odoo.git refs/heads/14.0:refs/git-autoshare/odoo/heads/14.0 --shallow-since=2020-10-01
26 changes: 26 additions & 0 deletions 15.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.10.12-alpine3.18

RUN apk fix && \
apk --no-cache --update add git git-lfs gpg less openssh patch bash && \
git lfs install

# we cannot use a more recent version for now
# see https://github.com/yaml/pyyaml/issues/724
# note that we install ak and git-aggregator to be able to do ak-build
# later in a builder image based on this image and ensure odoo/src
# is converged to the proper revision with the proper merges
RUN pip install PyYaml==5.3.1
RUN pip install git+https://github.com/akretion/ak

COPY repos.yml /root/.config/git-autoshare/repos.yml
RUN pip install git-autoshare git-aggregator
COPY bin/* /usr/local/bin/
COPY install/* /install/

# pre-fetch the git-autoshare cache with the bare minimum:
ADD https://api.github.com/repos/odoo/odoo/git/refs/heads/15.0 version.json
RUN mkdir -p /root/.cache/git-autoshare/github.com/odoo && \
cd /root/.cache/git-autoshare/github.com/odoo && \
/usr/bin/git init --bare && \
/usr/bin/git fetch https://github.com/OCA/OCB.git refs/heads/15.0:refs/git-autoshare/oca/heads/15.0 --shallow-since=2021-10-01 && \
/usr/bin/git fetch https://github.com/odoo/odoo.git refs/heads/15.0:refs/git-autoshare/odoo/heads/15.0 --shallow-since=2021-10-01
26 changes: 26 additions & 0 deletions 16.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.10.12-alpine3.18

RUN apk fix && \
apk --no-cache --update add git git-lfs gpg less openssh patch bash && \
git lfs install

# we cannot use a more recent version for now
# see https://github.com/yaml/pyyaml/issues/724
# note that we install ak and git-aggregator to be able to do ak-build
# later in a builder image based on this image and ensure odoo/src
# is converged to the proper revision with the proper merges
RUN pip install PyYaml==5.3.1
RUN pip install git+https://github.com/akretion/ak

COPY repos.yml /root/.config/git-autoshare/repos.yml
RUN pip install git-autoshare git-aggregator
COPY bin/* /usr/local/bin/
COPY install/* /install/

# pre-fetch the git-autoshare cache with the bare minimum:
ADD https://api.github.com/repos/odoo/odoo/git/refs/heads/16.0 version.json
RUN mkdir -p /root/.cache/git-autoshare/github.com/odoo && \
cd /root/.cache/git-autoshare/github.com/odoo && \
/usr/bin/git init --bare && \
/usr/bin/git fetch https://github.com/OCA/OCB.git refs/heads/16.0:refs/git-autoshare/oca/heads/16.0 --shallow-since=2022-10-01 && \
/usr/bin/git fetch https://github.com/odoo/odoo.git refs/heads/16.0:refs/git-autoshare/odoo/heads/16.0 --shallow-since=2022-10-01
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Odoo builder images

These auxiliary images are designed to be used in a multi-stages Docker build.
see https://docs.docker.com/build/building/multi-stage/

With traditional Odoo Dockerfiles, every time your base image get security updates (often once a week), all the Docker lines caches are swept and you rebuild the world, downloading 15 years of Odoo git history that weights 5.7 Gb. It can easily take 20 min in the cloud to 1h30 with a bad onsite connection...

With these base images, we pack the bare git-autoshare object references minimum to make the build always fast and light: git history objects are never copied in the production image, only the <250 Mb worktree is. The auxiliary base image weights also no more than 280 Mb because we use fetch --shallow-since the release date: so we can get the Odoo PR merges without carrying the whole "fatty odoo" git repo.

Cached builds still take less than 3 seconds while builds after security updates will not download anything from odoo/odoo, only copy the 250 Mb local worktree. And odoo-spec,yaml updates will not trigger large downloads either, only the git delta will be fetched. Most of these builds don't exceed 2 minutes.

Only a standard Dockerfile, no host hack.

0 comments on commit 706f60e

Please sign in to comment.