From 4bb57366f77c2f0bf7935c29556fbd92b488598e Mon Sep 17 00:00:00 2001 From: Vadim Musin Date: Sun, 10 Apr 2016 19:30:42 +0300 Subject: [PATCH] Hooks for persistent storage --- 8.0/Dockerfile | 14 +++++++++++--- 8.0/entrypoint.sh | 16 +++++++++++++--- 9.0/Dockerfile | 14 +++++++++++--- 9.0/entrypoint.sh | 15 ++++++++++++--- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/8.0/Dockerfile b/8.0/Dockerfile index 37e97f1..7c4e5fa 100644 --- a/8.0/Dockerfile +++ b/8.0/Dockerfile @@ -30,6 +30,17 @@ RUN set -x; \ && apt-get -y install -f --no-install-recommends \ && rm -rf /var/lib/apt/lists/* odoo.deb +# grab gosu for easy step-down from root +RUN gpg --keyserver pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN set -x; \ + apt-get update && apt-get install -y --no-install-recommends ca-certificates curl \ + && curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \ + && curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && rm -rf /var/lib/apt/lists/* + # Copy entrypoint script and Odoo configuration file COPY ./entrypoint.sh / COPY ./openerp-server.conf /etc/odoo/ @@ -46,8 +57,5 @@ EXPOSE 8069 8071 # Set the default config file ENV OPENERP_SERVER /etc/odoo/openerp-server.conf -# Set default user when running the container -USER odoo - ENTRYPOINT ["/entrypoint.sh"] CMD ["openerp-server"] diff --git a/8.0/entrypoint.sh b/8.0/entrypoint.sh index 8ec01b4..ce7d6e9 100755 --- a/8.0/entrypoint.sh +++ b/8.0/entrypoint.sh @@ -9,16 +9,26 @@ set -e : ${PGPASSWORD:=$DB_ENV_POSTGRES_PASSWORD} export PGHOST PGPORT PGUSER PGPASSWORD +if [[ ! -f /var/lib/odoo/etc/openerp-server.conf ]]; then + mkdir -p /var/lib/odoo/etc + mv /etc/odoo/openerp-server.conf /var/lib/odoo/etc/openerp-server.conf +else + rm -f /etc/odoo/openerp-server.conf +fi +ln -s /var/lib/odoo/etc/openerp-server.conf /etc/odoo/openerp-server.conf +chown -R odoo /var/lib/odoo + + case "$1" in --) shift - exec openerp-server "$@" + exec gosu odoo openerp-server "$@" ;; -*) - exec openerp-server "$@" + exec gosu odoo openerp-server "$@" ;; *) - exec "$@" + exec gosu odoo "$@" esac exit 1 diff --git a/9.0/Dockerfile b/9.0/Dockerfile index ed1bc36..3a42b06 100644 --- a/9.0/Dockerfile +++ b/9.0/Dockerfile @@ -30,6 +30,17 @@ RUN set -x; \ && apt-get -y install -f --no-install-recommends \ && rm -rf /var/lib/apt/lists/* odoo.deb +# grab gosu for easy step-down from root +RUN gpg --keyserver pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN set -x; \ + apt-get update && apt-get install -y --no-install-recommends ca-certificates curl \ + && curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \ + && curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && rm -rf /var/lib/apt/lists/* + # Copy entrypoint script and Odoo configuration file COPY ./entrypoint.sh / COPY ./openerp-server.conf /etc/odoo/ @@ -46,8 +57,5 @@ EXPOSE 8069 8071 # Set the default config file ENV OPENERP_SERVER /etc/odoo/openerp-server.conf -# Set default user when running the container -USER odoo - ENTRYPOINT ["/entrypoint.sh"] CMD ["openerp-server"] diff --git a/9.0/entrypoint.sh b/9.0/entrypoint.sh index 8ec01b4..6f69f10 100755 --- a/9.0/entrypoint.sh +++ b/9.0/entrypoint.sh @@ -9,16 +9,25 @@ set -e : ${PGPASSWORD:=$DB_ENV_POSTGRES_PASSWORD} export PGHOST PGPORT PGUSER PGPASSWORD +if [[ ! -f /var/lib/odoo/etc/openerp-server.conf ]]; then + mkdir -p /var/lib/odoo/etc + mv /etc/odoo/openerp-server.conf /var/lib/odoo/etc/openerp-server.conf +else + rm -f /etc/odoo/openerp-server.conf +fi +ln -s /var/lib/odoo/etc/openerp-server.conf /etc/odoo/openerp-server.conf +chown -R odoo /var/lib/odoo + case "$1" in --) shift - exec openerp-server "$@" + exec gosu odoo openerp-server "$@" ;; -*) - exec openerp-server "$@" + exec gosu odoo openerp-server "$@" ;; *) - exec "$@" + exec gosu odoo "$@" esac exit 1