domingo, 24 de diciembre de 2023

ODOO (V) : FALLA!!!: Curiosidades Docker-compose con Dockerfile

 1. Introducción. Curiosidad

Si queremos saber que hay dentro de la imagen que hemos descargado de ODOO16, basta con ir al repositorio oficial de odoo16 con docker y ver el contenido del "Dockerfile"

#01. Choose base image
FROM debian:bullseye-slim
MAINTAINER Odoo S.A. <info@odoo.com>

#02. Set theDockerfile de nginx default shell of the image.
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]

#03. Set environment variable to generate locale C.UTF-8 for postgres
# and general locale data
ENV LANG C.UTF-8

#04. The ARG instruction defines a variable that users can pass at build-time
# to the builder with the docker build command using the --build-arg <varname>=<value> flag.
# In this case retrieve the target architecture to install the correct wkhtmltopdf package
ARG TARGETARCH

#05. Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
dirmngr \
fonts-noto-cjk \
gnupg \
libssl-dev \
node-less \
npm \
python3-magic \
python3-num2words \
python3-odf \
python3-pdfminer \
python3-pip \
python3-phonenumbers \
python3-pyldap \
python3-qrcode \
python3-renderpm \
python3-setuptools \
python3-slugify \
python3-vobject \
python3-watchdog \
python3-xlrd \
python3-xlwt \
xz-utils && \
if [ -z "${TARGETARCH}" ]; then \
TARGETARCH="$(dpkg --print-architecture)"; \
fi; \
WKHTMLTOPDF_ARCH=${TARGETARCH} && \
case ${TARGETARCH} in \
"amd64") WKHTMLTOPDF_ARCH=amd64 && WKHTMLTOPDF_SHA=9df8dd7b1e99782f1cfa19aca665969bbd9cc159 ;; \
"arm64") WKHTMLTOPDF_SHA=58c84db46b11ba0e14abb77a32324b1c257f1f22 ;; \
"ppc64le" | "ppc64el") WKHTMLTOPDF_ARCH=ppc64el && WKHTMLTOPDF_SHA=7ed8f6dcedf5345a3dd4eeb58dc89704d862f9cd ;; \
esac \
&& curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bullseye_${WKHTMLTOPDF_ARCH}.deb \
&& echo ${WKHTMLTOPDF_SHA} wkhtmltox.deb | sha1sum -c - \
&& apt-get install -y --no-install-recommends ./wkhtmltox.deb \
&& rm -rf /var/lib/apt/lists/* wkhtmltox.deb

#05. Install latest postgresql-client
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main' > /etc/apt/sources.list.d/pgdg.list \
&& GNUPGHOME="$(mktemp -d)" \
&& export GNUPGHOME \
&& repokey='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8' \
&& gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${repokey}" \
&& gpg --batch --armor --export "${repokey}" > /etc/apt/trusted.gpg.d/pgdg.gpg.asc \
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" \
&& apt-get update \
&& apt-get install --no-install-recommends -y postgresql-client \
&& rm -f /etc/apt/sources.list.d/pgdg.list \
&& rm -rf /var/lib/apt/lists/*

#06. Install rtlcss (on Debian buster)RTLCSS is a framework for transforming Cascading Style Sheets (CSS) from Left-To-Right
RUN npm install -g rtlcss

#07. Install Odoo
ENV ODOO_VERSION 16.0
ARG ODOO_RELEASE=20231222
ARG ODOO_SHA=739d7dd119c00fa27ab1bcd140b70389ce271170
RUN curl -o odoo.deb -sSL http://nightly.odoo.com/${ODOO_VERSION}/nightly/deb/odoo_${ODOO_VERSION}.${ODOO_RELEASE}_all.deb \
&& echo "${ODOO_SHA} odoo.deb" | sha1sum -c - \
&& apt-get update \
&& apt-get -y install --no-install-recommends ./odoo.deb \
&& rm -rf /var/lib/apt/lists/* odoo.deb

#08. Copy entrypoint script and Odoo configuration file
COPY ./entrypoint.sh /
COPY ./odoo.conf /etc/odoo/

#09. Set permissions and Mount /var/lib/odoo to allow restoring filestore and /mnt/extra-addons for users addons
RUN chown odoo /etc/odoo/odoo.conf \
&& mkdir -p /mnt/extra-addons \
&& chown -R odoo /mnt/extra-addons
VOLUME ["/var/lib/odoo", "/mnt/extra-addons"]

#10. Expose Odoo services
EXPOSE 8069 8071 8072

#11. Set the default config file
ENV ODOO_RC /etc/odoo/odoo.conf

COPY wait-for-psql.py /usr/local/bin/wait-for-psql.py

#12. Set default user when running the container
USER odoo

ENTRYPOINT ["/entrypoint.sh"]
CMD ["odoo"]


2. FALLA:Curiosidad: Instalar Odoo+Postgres+Nginx usando docker-compose y los respectivos dockerfiles.

Si queremos complicar un poco el asunto pero entender un poco como se pueden utilizar docker-compose junto con dockerfiles hacemos:

  1. Crear una carpeta por ejemplo prueba06 y siturarnos en ella
  2. Descargar el Dockerfile de Odoo16 y lo renombramos a odoo.dockerfile.
  3. Descargar el Dockerfile de Postgres13 y lo renombramos a postgres.dockerfile.
  4. Descargar el Dockerfile de nginx y lo renombramos a nginx.dockerfile.

Y ahora creamos un nuevo docker-compose.yml en base al anterior pero cambiando image: por dockerfile: 

Pero al hacer docker-compose falla!

version: '3.3'
services:
    odoo:
        container_name: odoo16_02
        #image: odoo:16.0
        build: 
            context: .
            dockerfile: odoo.dockerfile
        env_file: odoo16_pg13.env                 # environment file
        depends_on:
            - postgresql
        ports:
            - "7069:8069"                         #port mapping(custom-port:8069)
        volumes:
            - ./odoo-data/:/var/lib/odoo
            - ./odoo-conf/:/etc/odoo
            - ./odoo-adds/:/odoo/extra-addons      #SAME AS odoo.conf addons_path
        #--Edu (1)
        networks:
            odoo_network:
                aliases: 
                    - odoo_host
                #ipv4_adress: 172.21.0.4 
        #Fi--Edu (1)
    postgresql:
        container_name: postgres_odoo_02
        #image: postgres:13
        build: 
            context: .
            dockerfile: postgres.dockerfile
        env_file: odoo16_pg13.env               # environment file
        volumes:
            - ./postgresql-data/:/var/lib/postgresql/data/pgdata  ##SAME AS odoo16_pg13.env PGDAT [4]
        #--Edu (1)
        networks:
            odoo_network:
                aliases: 
                    - postgres_host
                #ipv4_adress: 172.21.0.2 
        #Fi--Edu (1)
    nginx:
        container_name: nginx_odoo_02
        #image: nginx:latest
        build: 
            context: .
            dockerfile: nginx.dockerfile
        depends_on:
            - odoo
        ports:
            - "7080:80"
            - "7443:443"
        #1. Copiar la CARPETA de certificados a la carpeta ./nginx-certs
        #2. Copiar el FICHERO de configuración del proxy nginx.conf   a la carpeta ./nginx-etc/nginx/conf.d
        volumes:
            - ./nginx-certs:/etc/nginx/certs
        #    - ./nginx-log/:/var/log
        #    - ./nginx-conf/odoo-nginx.conf:/etc/nginx/conf.d/odoo-nginx.conf
            - ./nginx-conf/odoo-nginx.conf:/etc/nginx/conf.d/default.conf
        #--Edu (1)
        networks:
            odoo_network:
                aliases: 
                    - nginx_host
                #ipv4_adress: 172.21.0.3 
        #Fi--Edu (1)
volumes:
    odoo-data: {}
    odoo-conf: {}
    odoo-adds: {}

    postgresql-data: {}

    nginx-certs: {}
    #nginx-conf/odoo-nginx.conf: {}    #?????????

#--Edu (1)            
networks:
    odoo_network:
        #name: odoo_net
        driver: bridge 
        #ipam:
        #    driver: DEFAULT
                #- subnet: 172.21.0.0/16
                #- gateway: 172.21.0.1  #Optional

#Fi--Edu (1)









No hay comentarios :

Publicar un comentario