[FIX] docker odoo execution connect to database

- Database manager works when use postgres_db postgres
- Add volume for postgres
- Add script to build docker
- Documentation of docker usage
This commit is contained in:
Mathieu Benoit 2020-07-28 06:09:58 -04:00
parent 0b9464cb94
commit 2f21c94c9d
9 changed files with 162 additions and 81 deletions

View file

@ -64,6 +64,13 @@ Simply update all feature.
./run.sh --limit-time-real 99999 --stop-after-init -u all -d DATABASE
```
# Postgresql
To show config file:
> psql -U postgres -c 'SHOW config_file'
Edit this file to accept interface from all network:
> /var/lib/postgres/data/postgresql.conf
# Delete an instance in production
Caution, this delete home of users, it's irrevocable.
```bash

View file

@ -5,20 +5,24 @@ services:
# image: technolibre/erplibre:12.0-src
ports:
- 8069:8069
- 8071:8071
- 8072:8072
environment:
HOST: db
PASSWORD: mysecretpassword
USER: odoo
POSTGRES_DB: odoo
CURRENT_UID: ${CURRENT_UID}
POSTGRES_DB: postgres
# CURRENT_UID: ${CURRENT_UID}
depends_on:
- db
networks:
- front
command: odoo -c /ERPLibre/odoo/odoo.conf --without-demo=ALL -i base -d odoo
# networks:
# - front
#entrypoint: odoo
#command: bash -c "sleep 1000 && odoo --without-demo=ALL -i base -d odoo "
command: odoo
# user:
volumes:
- .:/ERPLibre
# - .:/ERPLibre
# See the volume section at the end of the file
- erplibre_data_dir:/var/lib/odoo
@ -27,22 +31,26 @@ services:
environment:
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_USER: odoo
POSTGRES_DB: odoo
networks:
- front
POSTGRES_DB: postgres
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- erplibre-db-data:/var/lib/postgresql/data/pgdata
#networks:
# - front
networks:
front:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.237.0/24
#networks:
# front:
#
# driver: bridge
# ipam:
# driver: default
# config:
# - subnet: 172.16.237.0/24
# We configure volume without specific destination to let docket manage it. To configure it through docker use (read related documentation before continuing) :
# - docker volume --help
# - docker-compose down --help
volumes:
erplibre_data_dir:
erplibre-db-data:

View file

@ -6,8 +6,8 @@ SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
# Generate locale C.UTF-8 for postgres and general locale data
ENV LANG C.UTF-8
ENV ODOO_EXEC_BIN odoo
ENV ODOO_PREFIX /ERPLibre
ENV ODOO_EXEC_BIN $ODOO_PREFIX/odoo/odoo-bin
# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf

View file

@ -28,10 +28,6 @@ ENV ENV=dev
COPY ./entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENV ODOO_PREFIX /ERPLibre
ENV ODOO_EXEC_BIN $ODOO_PREFIX/odoo/odoo-bin
COPY repo_manifest_gen_org_prefix_path.py /usr/bin/
RUN chmod +x /usr/bin/repo_manifest_gen_org_prefix_path.py

View file

@ -1,19 +1,20 @@
FROM technolibre/erplibre-base:12.0
ENV REPO_MANIFEST_URL https://github.com/agileops/ERPLibre.git
ENV REPO_MANIFEST_URL http://git.erplibre.ca/ERPLibre
RUN cat /etc/os-release
ENV BRANCH_ERPLIBRE dev/1.1.0
USER root
# Install Odoo
ENV ODOO_VERSION 12.0
ARG ODOO_RELEASE=20200417
ARG ODOO_SHA=ca4a7485b0b75850ffe1458a8f3266839400a501
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 -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew install --no-install-recommends ./odoo.deb \
&& rm -rf /var/lib/apt/lists/* odoo.deb
#ENV ODOO_VERSION 12.0
#ARG ODOO_RELEASE=20200417
#ARG ODOO_SHA=ca4a7485b0b75850ffe1458a8f3266839400a501
#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 -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew install --no-install-recommends ./odoo.deb \
# && rm -rf /var/lib/apt/lists/* odoo.deb
RUN mkdir ~/.ssh/ && echo "StrictHostKeyChecking no" >> ~/.ssh/config && apt update && apt install ssh-client git -y --no-install-recommends && \
@ -24,7 +25,7 @@ RUN cd ; mkdir -p .bin/ && \
git config --global user.email "foo@bar.io" && \
git config --global user.name "Foo Bar" && \
mkdir -p $ODOO_PREFIX && cd $ODOO_PREFIX && \
repo init -u $REPO_MANIFEST_URL -b 12.0_repo && \
repo init -u $REPO_MANIFEST_URL -b $BRANCH_ERPLIBRE && \
repo sync -j 4 -c
ADD repo_manifest_gen_org_prefix_path.py /root/.bin/

View file

@ -2,32 +2,95 @@
Those image are prepare to permit better portability and reproducibility of ERPLibre release.
Due the the growing code of ERPLibre, it could also simplify developpement.
Due the the growing code of ERPLibre, it could also simplify development.
NOTE : Those Dockerfile themselve are in heavy developpement for now. Incompatibilities between release are normal until the interfaces will be stabilized.
NOTE: Those Dockerfile themselve are in heavy development for now. Incompatibilities between release are normal until the interfaces will be stabilized.
## Pre-requierments
## Pre-requirements
- Basic knownledge with Docker, Linux and bash
- Basic knowledge with Docker, Linux and bash
- Latest Docker version
## Files representations
- Dockerfile.base : This Dockerfile represent the base Docker image layer reused by other child layersé
- Dockerfile.dev : This Dockerfile is specialized in developpement.
- Dockerfile.prod{pkg,src} : Dockerfile.prod.\* is a Docker image specialized for production systems. Dockerfile.prod.pkg reuse official debian files from Odoo.com. Dockerfile.prod.src fetch the Odoo source code as the ERPLibre runtime.
- Dockerfile.base: This Dockerfile represent the base Docker image layer reused by other child layers
- Dockerfile.dev: This Dockerfile is specialized in development.
- Dockerfile.prod{pkg,src}: Dockerfile.prod.\* is a Docker image specialized for production systems. Dockerfile.prod.pkg reuse official Debian files from Odoo.com. Dockerfile.prod.src fetch the Odoo source code as the ERPLibre runtime.
## Getting started
### Building the dockerimages
Be sure to start daemon docker
```bash
systemctl start docker
```
- docker build -f Dockerfile.base -t technolibre/erplibre-base:12.0 .
- docker build -f Dockerfile.prod.pkg .
### Building the docker images
```bash
cd docker
docker build -f Dockerfile.base -t technolibre/erplibre-base:12.0 .
docker build -f Dockerfile.prod.pkg -t technolibre/erplibre:12.0-pkg .
```
### Running ERPLibre using Docker-Compose
1. Go at the root of this git project. Ex : `cd ERPLibre`
2. docker-compose -f docker-compose.yml up
Go at the root of this git project.
```bash
cd ERPLibre
docker-compose -f docker-compose.yml up
```
### Diagnostic Docker-Compose
Show docker-compose information
```bash
docker-compose ps
docker-compose logs IMAGE_NAME
```
Show docker information
```bash
docker ps -a
docker volume ls
docker inspect DOCKER_NAME
```
Connect to a running docker
```bash
docker exec -ti DOCKER_NAME bash
docker exec -u root -ti DOCKER_NAME bash
```
Interesting command to debug
```bash
docker run -p 8069:8069 --entrypoint bash -ti DOCKER_NAME
docker exec -ti DOCKER_NAME bash
docker exec -u root -ti DOCKER_NAME bash
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_USER=odoo -e POSTGRES_DB=postgres postgre
export
db_host = "host.docker.internal"
```
### Cleaning
Delete docker image
```bash
docker image prune
```
Delete volumes
```bash
docker-compose rm -v
```
Delete containers
```bash
docker rm $(docker ps -a | grep -v IMAGE | awk '{print $1}')
```
Delete volume
```bash
docker volume prune
```

View file

@ -54,35 +54,35 @@
#-----------------------------------------------------------------------------
# Specify the database password for db_user (default None)
#-----------------------------------------------------------------------------
db_password = 00aa9df39b0c99ac3d1d8412d2917175
#db_password = 00aa9df39b0c99ac3d1d8412d2917175
#-----------------------------------------------------------------------------
# Specify the database name.
#-----------------------------------------------------------------------------
db_name = False
#db_name = False
#-----------------------------------------------------------------------------
# DataError: new encoding (UTF8) is incompatible with the encoding of the
# template database (SQL_ASCII) HINT: Use the same encoding as in the template
# database, or use template0 as template.
#-----------------------------------------------------------------------------
db_template = template0
# db_template = template0
#-----------------------------------------------------------------------------
# Master Database password
# This is set at first boot, and can be set from within Odoo
#-----------------------------------------------------------------------------
admin_passwd = 12357
#admin_passwd = 12357
#-----------------------------------------------------------------------------
# specify the the maximum number of physical connections to posgresql
#-----------------------------------------------------------------------------
db_maxconn = 64
#db_maxconn = 64
#-----------------------------------------------------------------------------
# Filter listed database REGEXP
#-----------------------------------------------------------------------------
dbfilter = .*
#dbfilter = .*
@ -151,19 +151,19 @@ dbfilter = .*
#-----------------------------------------------------------------------------
# Ture/False. If True, also write log to 'ir_logging' table in database
#-----------------------------------------------------------------------------
log-db = True
; log-db = True
#-----------------------------------------------------------------------------
# True/False logs to the system's event logger: syslog
#-----------------------------------------------------------------------------
syslog = False
; syslog = False
#-----------------------------------------------------------------------------
# Log level - One of the following:
# info, debug_rpc, warn, test, critical, debug_sql, error, debug,
# debug_rpc_answer
#-----------------------------------------------------------------------------
log-level = warn
; log-level = warn
#-----------------------------------------------------------------------------
# log_handler - can be a list of 'module:log_level' pairs.
@ -193,13 +193,13 @@ port = 8069
#-----------------------------------------------------------------------------
# Launch server over https instead of http (default False).
#-----------------------------------------------------------------------------
secure = False
; secure = False
#-----------------------------------------------------------------------------
# Set to True if you are deploying your App behind a proxy
# e.g. Apache using mod_proxy. --proxy_mode added, using Werkzeug ProxyFix class
#-----------------------------------------------------------------------------
proxy_mode = True
#proxy_mode = True
#-----------------------------------------------------------------------------
# Specify the addons_path folders ordered by priority
@ -216,17 +216,17 @@ addons_path = /opt/openerp/odoo/addons,/home/myaddons
#-----------------------------------------------------------------------------
# specify reference timezone for the server (e.g. Europe/Brussels)
#-----------------------------------------------------------------------------
timezone = False
; timezone = False
#-----------------------------------------------------------------------------
# specify the certificate file for the SSL connection
#-----------------------------------------------------------------------------
secure_cert_file = server.cert
; secure_cert_file = server.cert
#-----------------------------------------------------------------------------
# specify the private key file for the SSL connection
#-----------------------------------------------------------------------------
secure_pkey_file = server.pkey
; secure_pkey_file = server.pkey
#-----------------------------------------------------------------------------
# XML-RPC Secure Configuration (disabled if ssl is unavailable):
@ -235,8 +235,8 @@ secure_pkey_file = server.pkey
# protocol. The empty string binds to all interfaces.
# xmlrpcs_port - Specify the TCP port for the XML-RPC Secure protocol
#-----------------------------------------------------------------------------
xmlrpcs = True
xmlrpcs_interface = 127.0.0.1
; xmlrpcs = True
#xmlrpcs_interface = 127.0.0.1
xmlrpcs_port = 8071
#-----------------------------------------------------------------------------
@ -246,8 +246,8 @@ xmlrpcs_port = 8071
# protocol. The empty string binds to all interfaces.
# xmlrpc_port - Specify the TCP port for the XML-RPC protocol
#-----------------------------------------------------------------------------
xmlrpc = True
xmlrpc_interface = 127.0.0.1
; xmlrpc = True
#xmlrpc_interface = 127.0.0.1
xmlrpc_port = 8069
#-----------------------------------------------------------------------------
@ -262,22 +262,22 @@ longpolling_port = 8072
# at the current state. Provide a filename to store intermediate importation
# states.
#-----------------------------------------------------------------------------
import_partial =
; import_partial =
#-----------------------------------------------------------------------------
# Use the unaccent function provided by the database when available
#-----------------------------------------------------------------------------
unaccent = False
; unaccent = False
#-----------------------------------------------------------------------------
# specify modules to export. Use in combination with --i18n-export
#-----------------------------------------------------------------------------
translate_modules = ['all']
; translate_modules = ['all']
#-----------------------------------------------------------------------------
# Comma-separated list of server-wide modules, default=web
#-----------------------------------------------------------------------------
server_wide_modules = None
; server_wide_modules = None
@ -288,32 +288,32 @@ server_wide_modules = None
#-----------------------------------------------------------------------------
# Specify the SMTP server for sending email (default localhost).
#-----------------------------------------------------------------------------
smtp_server = localhost
; smtp_server = localhost
#-----------------------------------------------------------------------------
# Specify the SMTP user for sending email (default False).
#-----------------------------------------------------------------------------
smtp_user = False
; smtp_user = False
#-----------------------------------------------------------------------------
# Specify the SMTP password for sending email (default False).
#-----------------------------------------------------------------------------
smtp_password = False
; smtp_password = False
#-----------------------------------------------------------------------------
# if True, SMTP connections will be encrypted with SSL (STARTTLS)
#-----------------------------------------------------------------------------
smtp_ssl = False
; smtp_ssl = False
#-----------------------------------------------------------------------------
# Specify the SMTP email address for sending email
#-----------------------------------------------------------------------------
email_from = "TKL-Odoo-Server@example.com"
; email_from = "TKL-Odoo-Server@example.com"
#-----------------------------------------------------------------------------
# Specify the SMTP port
#-----------------------------------------------------------------------------
smtp_port = 25
; smtp_port = 25
@ -499,22 +499,22 @@ osv_memory_age_limit = 1.0
#-----------------------------------------------------------------------------
# Enable YAML and unit tests.
#-----------------------------------------------------------------------------
test_enable = False
; test_enable = False
#-----------------------------------------------------------------------------
# Launch a python or YML test file.
#-----------------------------------------------------------------------------
test_file = False
; test_file = False
#-----------------------------------------------------------------------------
# If set, will save sample of all reports in this directory.
#-----------------------------------------------------------------------------
test_report_directory = False
; test_report_directory = False
#-----------------------------------------------------------------------------
# Commit database changes performed by YAML or XML tests.
#-----------------------------------------------------------------------------
test_commit = False
; test_commit = False
#-----------------------------------------------------------------------------
# disable loading demo data for modules to be installed (comma-separated, use

View file

@ -4,7 +4,6 @@ import psycopg2
import sys
import time
if __name__ == '__main__':
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--db_host', required=True)
@ -21,10 +20,11 @@ if __name__ == '__main__':
connected = False
error = ''
while ((time.time() - start_time) < args.timeout ) or connected is True:
while ((time.time() - start_time) < args.timeout) or connected is True:
try:
conn = psycopg2.connect(user=args.db_user, host=args.db_host, port=args.db_port, password=args.db_password, dbname="odoo")
conn = psycopg2.connect(user=args.db_user, host=args.db_host,
port=args.db_port, password=args.db_password,
dbname="postgres")
break
except psycopg2.OperationalError as e:

6
script/build_docker.sh Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
cd docker
docker build -f Dockerfile.base -t technolibre/erplibre-base:12.0 .
docker build -f Dockerfile.prod.pkg -t technolibre/erplibre:12.0-pkg .
cd ..
docker-compose up -d