上QQ阅读APP看书,第一时间看更新
Building a Docker image
To build a Docker image from your development environment, follow the following steps:
- Go to the project directory, and a file called .dockerignore with the following content:
env
**/*~
**/*.pyc
**/.git
filestore
- Create a file bin/docker-entrypoint.sh with the following content:
#!/bin/bash
ODOO=/srv/odoo/src/odoo/odoo-bin
$ODOO --addons-path="$ODOO_ADDONS_PATH" \
-d "$ODOO_DB_NAME" \
--db_host="$ODOO_DB_HOST" \
--db_user="$ODOO_DB_USER" \
--db_password="$ODOO_DB_PASSWORD" \
--no-database-list \
--db-filter="$ODOO_DB_FILTER" \
--db_port="$ODOO_DB_PORT" \
--data-dir=/filestore "$@"
- Make the file executable:
$ chmod +x bin/docker-entrypoint.sh
- Create a file called Dockerfile with the following content:
FROM debian:stretch
LABEL version="1.1" \
maintainer="Alexandre Fayolle
<alexandre.fayolle@camptocamp.com>" \
description="Example docker image for the bookshelf project"
CMD ["/srv/odoo/bin/odoo"]
ENV ODOO_ADDONS_PATH="src/odoo/odoo/addons,src/odoo/addons,local/" \
ODOO_DB_HOST=odoo \
ODOO_DB_NAME=odoodb \
ODOO_DB_filter=odoodb$ \
ODOO_LIST_DB=False \
ODOO_DB_USER=odoo \
ODOO_DB_PASSWORD=odoo \
ODOO_DB_PORT=5432 \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8
VOLUME ["/filestore"]
WORKDIR /srv/odoo
COPY src/odoo/requirements.txt /srv/odoo/src/odoo/
RUN mkdir local bin \
&& \
apt-get update \
&& \
apt-get install -y \
fontconfig \
libfreetype6 \
libx11-6 \
libxext6 \
libxrender1 \
node-clean-css \
node-less \
python3-pip \
virtualenv \
python3.5 \
wget \
xfonts-75dpi \
xfonts-base \
xz-utils \
zlib1g \
&& \
apt-get install -y \
gcc \
libevent-dev \
libjpeg-dev \
libldap2-dev \
libpng-dev \
libpq-dev \
libsasl2-dev \
libxml2-dev \
libxslt1-dev \
python3.5-dev \
&& \
pip3 install --no-cache-dir -r src/odoo/requirements.txt \
&& \
apt-get remove --purge --autoremove -y \
gcc \
g++ \
&& \
wget -qO wkhtmltox.tar.xz \ https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz \
&& \
tar -xf wkhtmltox.tar.xz \
&& \
install wkhtmltox/lib/* /usr/lib \
&& \
install wkhtmltox/bin/* /usr/bin \
&& \
rm -rf wkhtmltox wkhtmltox.tar.xz \
&& \
apt-get remove --purge -y \
libevent-dev \
libjpeg-dev \
libldap2-dev \
libpng-dev \
libpq-dev \
libsasl2-dev \
libxml2-dev \
libxslt1-dev \
python3.5-dev \
wget \
xz-utils\
&& \
apt-get clean \
;
COPY . /srv/odoo
RUN mv bin/docker-entrypoint.sh bin/odoo
- Build the docker image with this command:
$ docker build -t yourcompany/yourproject .
- Create a file called docker-compose.yml with the following content:
version: '2'
services:
odoo:
build: .
image: yourcompany/yourproject
depends_on:
- db
volumes:
- "data-odoo:/filestore"
environment:
- ODOO_DB_USER=odoo
- ODOO_DB_PASSWORD=odoo
- ODOO_DB_NAME=odoodb
- ODOO_DB_HOST=db
- ODOO_ADMIN_PASSWORD=randompass
ports:
- 8069
- 8072
restart: always
db:
image: postgres:9.6
environment:
- POSTGRES_USER=odoo
- POSTGRES_PASSWORD=odoo
- POSTGRES_DB=odoodb
- PG_SYSTEM_SHARED_BUFFERS=256MB
- PG_SYSTEM_MAINTENANCE_WORK_MEM=256MB
- PG_SYSTEM_WAL_BUFFERS=8MB
- PG_SYSTEM_EFFECTIVE_CACHE_SIZE=1024MB
volumes:
- "data-db:/var/lib/postgresql/data"
volumes:
data-odoo:
data-db:
- Save your Docker image:
$ docker save yourcompany/yourproject | gzip > yourproject.image.tar.gz