odoo / docker

Other
932 stars 1.52k forks source link

Install amazon-efs-utils and python3-boto3 packages. #367

Closed amh-mw closed 3 months ago

amh-mw commented 3 years ago

A better solution might be to base a new image off of Amazon Linux instead of debian:buster-slim, but this was a lower cost way to let me write Odoo modules that interface with AWS. I tag this as 13-amazon locally.

lathama commented 3 months ago

@amh-mw this might be a good use of https://docs.docker.com/build/building/multi-stage/

Please close this if no longer needed.

amh-mw commented 3 months ago

@lathama Yes, I did end up using multi-stage builds to address this:

ARG version=15

# https://docs.aws.amazon.com/efs/latest/ug/installing-amazon-efs-utils.html#installing-other-distro
# Build amazon-efs-utils package.
FROM debian:buster-slim AS efs-utils
RUN apt-get update && apt-get -y install binutils
COPY ./efs-utils /usr/local/src/efs-utils
WORKDIR /usr/local/src/efs-utils
RUN ./build-deb.sh

################################################
FROM odoo:$version AS web

USER root

# Install amazon-efs-utils and python3-boto3 packages.
COPY --from=efs-utils /usr/local/src/efs-utils/build/*.deb /tmp
RUN apt-get update && apt-get install -y python3-boto3 /tmp/amazon-efs-utils*.deb && rm -rf /var/lib/apt/lists/* /tmp/*.deb

# Hack around inability to install -r requirements.txt from mount
ADD requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt
RUN rm /tmp/requirements.txt

# Apply patches
RUN apt-get update && apt-get install patch && rm -rf /var/lib/apt/lists/*
COPY ./patches /tmp/
RUN cat /tmp/*.diff | patch -sd /usr/lib/python3/dist-packages/odoo -p1
RUN rm /tmp/*.diff
USER odoo

# TODO Submitted upstream; https://github.com/odoo/docker/pull/425
HEALTHCHECK CMD curl --fail http://localhost:8069/web/health || exit 1

################################################
FROM web AS test
USER root

COPY apt.preferences /etc/apt/preferences

# Install chromium testing requirements
RUN apt-get update && \
    apt-get install -y --no-install-recommends chromium && \
    rm -rf /var/lib/apt/lists/*

# Install python testing requirements
RUN pip3 install websocket-client

USER odoo

Closing.