Hooks for persistent storage

This commit is contained in:
Vadim Musin 2016-04-10 19:30:42 +03:00
parent f13ffb4c91
commit 4bb57366f7
4 changed files with 47 additions and 12 deletions

View File

@ -30,6 +30,17 @@ RUN set -x; \
&& apt-get -y install -f --no-install-recommends \ && apt-get -y install -f --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* odoo.deb && 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 script and Odoo configuration file
COPY ./entrypoint.sh / COPY ./entrypoint.sh /
COPY ./openerp-server.conf /etc/odoo/ COPY ./openerp-server.conf /etc/odoo/
@ -46,8 +57,5 @@ EXPOSE 8069 8071
# Set the default config file # Set the default config file
ENV OPENERP_SERVER /etc/odoo/openerp-server.conf ENV OPENERP_SERVER /etc/odoo/openerp-server.conf
# Set default user when running the container
USER odoo
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["openerp-server"] CMD ["openerp-server"]

View File

@ -9,16 +9,26 @@ set -e
: ${PGPASSWORD:=$DB_ENV_POSTGRES_PASSWORD} : ${PGPASSWORD:=$DB_ENV_POSTGRES_PASSWORD}
export PGHOST PGPORT PGUSER PGPASSWORD 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 case "$1" in
--) --)
shift shift
exec openerp-server "$@" exec gosu odoo openerp-server "$@"
;; ;;
-*) -*)
exec openerp-server "$@" exec gosu odoo openerp-server "$@"
;; ;;
*) *)
exec "$@" exec gosu odoo "$@"
esac esac
exit 1 exit 1

View File

@ -30,6 +30,17 @@ RUN set -x; \
&& apt-get -y install -f --no-install-recommends \ && apt-get -y install -f --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* odoo.deb && 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 script and Odoo configuration file
COPY ./entrypoint.sh / COPY ./entrypoint.sh /
COPY ./openerp-server.conf /etc/odoo/ COPY ./openerp-server.conf /etc/odoo/
@ -46,8 +57,5 @@ EXPOSE 8069 8071
# Set the default config file # Set the default config file
ENV OPENERP_SERVER /etc/odoo/openerp-server.conf ENV OPENERP_SERVER /etc/odoo/openerp-server.conf
# Set default user when running the container
USER odoo
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["openerp-server"] CMD ["openerp-server"]

View File

@ -9,16 +9,25 @@ set -e
: ${PGPASSWORD:=$DB_ENV_POSTGRES_PASSWORD} : ${PGPASSWORD:=$DB_ENV_POSTGRES_PASSWORD}
export PGHOST PGPORT PGUSER PGPASSWORD 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 case "$1" in
--) --)
shift shift
exec openerp-server "$@" exec gosu odoo openerp-server "$@"
;; ;;
-*) -*)
exec openerp-server "$@" exec gosu odoo openerp-server "$@"
;; ;;
*) *)
exec "$@" exec gosu odoo "$@"
esac esac
exit 1 exit 1