general enhancements

This commit is contained in:
Yhael S
2023-08-26 16:23:45 -05:00
parent f96c483ec1
commit 0ceb528e26
8 changed files with 70 additions and 57 deletions

View File

@@ -1,22 +1,14 @@
#--------------------------# #--------------------------#
# Main Configuration # # Main Configuration #
#--------------------------# #--------------------------#
# Project
PROJECT_NAME=odoocker
DOMAIN=erp.odoocker.test
SUPPORT_EMAIL=mail@example.com
CORS_ALLOWED_DOMAIN="'http://external-domain.test'"
# App
APP_ENV=fresh
DEV_MODE=reload,qweb
# Odoo # Odoo
ODOO_VERSION=14.0 APP_ENV=fresh
UPDATE=
INIT= INIT=
UPDATE=
LOAD=base,web LOAD=base,web
WORKERS=1 WORKERS=1
DEV_MODE=reload,qweb
DOMAIN=erp.odoocker.test
# Enterprise # Enterprise
GITHUB_USER= GITHUB_USER=
@@ -29,21 +21,21 @@ DB_PORT=5432
DB_NAME=odoo DB_NAME=odoo
DB_USER=odoo DB_USER=odoo
DB_PASSWORD=odoo DB_PASSWORD=odoo
LOAD_LANGUAGE=
DB_SSLMODE=prefer DB_SSLMODE=prefer
DB_MAXCONN=64 DB_MAXCONN=64
DB_TEMPLATE=unaccent_template DB_TEMPLATE=unaccent_template
UNACCENT=True UNACCENT=True
LIST_DB=True LIST_DB=True
DBFILTER=.* DBFILTER=.*
LOAD_LANGUAGE=
# Logging # Logging
LOG_LEVEL=info LOG_LEVEL=info
LOG_HANDLER="[':INFO']" LOG_HANDLER="[':INFO']"
# PgAdmin # Nginx
PGADMIN_DOMAIN=pgadmin.odoocker.test CORS_ALLOWED_DOMAIN="'http://external-domain.test'"
PGADMIN_PASSWORD=odoo
# Testing # Testing
TEST_ENABLE=False TEST_ENABLE=False
@@ -59,16 +51,24 @@ SMTP_PASSWORD=
EMAIL_FROM= EMAIL_FROM=
FROM_FILTER= FROM_FILTER=
# PgAdmin
PGADMIN_DOMAIN=pgadmin.odoocker.test
PGADMIN_PASSWORD=odoo
#------------------------------# #------------------------------#
# Project Configurations # # Project Configurations #
#------------------------------# #------------------------------#
PROJECT_NAME=${PROJECT_NAME} # Docker
DOMAIN=${DOMAIN} PROJECT_NAME=odoocker
SUPPORT_EMAIL=${SUPPORT_EMAIL} SUPPORT_EMAIL=mail@example.com
ODOO_VERSION=${ODOO_VERSION}
GITHUB_USER=${GITHUB_USER} # Containers Tags
GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} ODOO_TAG=14.0
ENTERPRISE_REPO=https://${GITHUB_USER}:${GITHUB_ACCESS_TOKEN}@github.com/odoo/enterprise.git POSTGRES_TAG=15.4
NGINX_TAG=1.25.2
NGINX_PROXY_TAG=1.3.1
ACME_COMPANION_TAG=2.2.8
PGADMIN_TAG=7.6
#------------# #------------#
# Odoo # # Odoo #

View File

@@ -77,7 +77,6 @@ This file is divided in sections, you most likely are going to focus on the `Mai
Sample `.env` file: Sample `.env` file:
``` ```
# Odoo # Odoo
ODOO_VERSION=16.0
UPDATE=custom_account_addon UPDATE=custom_account_addon
INIT= INIT=
LOAD=base,web LOAD=base,web
@@ -164,6 +163,18 @@ docker-compose up -d --build && docker-compose logs odoo
# Pro(d) Tips # Pro(d) Tips
The following tips will enhance your developing and production experience. The following tips will enhance your developing and production experience.
## 1. Search through Community, Enterprise, Extra & Custom Addons at once:
If you are using `Visual Studio Code` & the Remote
```
alias odoo='cd odoocker'
alias hard-deploy='docker-compose down && git pull && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo'
alias deploy='docker-compose down && git pull && docker-compose up -d --build && docker-compose logs -f --tail 2000 odoo'
alias logs='docker-compose logs -f --tail 2000 odoo'
```
## 1. Define the following aliases: ## 1. Define the following aliases:
``` ```
alias odoo='cd odoocker' alias odoo='cd odoocker'

View File

@@ -18,7 +18,7 @@ services:
- 443:443 - 443:443
letsencrypt: letsencrypt:
image: nginxproxy/acme-companion:2.2.8 image: nginxproxy/acme-companion:${ACME_COMPANION_TAG}
depends_on: depends_on:
- nginx-proxy - nginx-proxy
restart: unless-stopped restart: unless-stopped

View File

@@ -1,6 +1,6 @@
services: services:
pgadmin: pgadmin:
image: dpage/pgadmin4:7.4 image: dpage/pgadmin4:${PGADMIN_TAG}
restart: unless-stopped restart: unless-stopped
expose: expose:
- 80 - 80

View File

@@ -4,12 +4,11 @@ services:
context: ./ context: ./
dockerfile: ./odoo/Dockerfile dockerfile: ./odoo/Dockerfile
args: args:
- ODOO_VERSION - ODOO_TAG
- ODOO_RC - ODOO_RC
- ROOT_PATH - ROOT_PATH
- GITHUB_USER - GITHUB_USER
- GITHUB_ACCESS_TOKEN - GITHUB_ACCESS_TOKEN
- ENTERPRISE_REPO
- ENTERPRISE_ADDONS - ENTERPRISE_ADDONS
- LOG_PATH - LOG_PATH
depends_on: depends_on:
@@ -30,6 +29,8 @@ services:
build: build:
context: ./postgres context: ./postgres
dockerfile: Dockerfile dockerfile: Dockerfile
args:
- POSTGRES_TAG
restart: unless-stopped restart: unless-stopped
tty: true tty: true
volumes: volumes:
@@ -44,7 +45,7 @@ services:
- internal - internal
nginx: nginx:
image: nginx:1.25.1 image: nginx:${NGINX_TAG}
depends_on: depends_on:
- odoo - odoo
restart: unless-stopped restart: unless-stopped
@@ -63,7 +64,7 @@ services:
- internal - internal
nginx-proxy: nginx-proxy:
image: nginxproxy/nginx-proxy:1.3.1 image: nginxproxy/nginx-proxy:${NGINX_PROXY_TAG}
depends_on: depends_on:
- nginx - nginx
restart: unless-stopped restart: unless-stopped

View File

@@ -1,26 +1,25 @@
#------------------------# #------------------------#
# Odoo Community # # Odoo Community #
#------------------------# #------------------------#
ARG ODOO_VERSION ARG ODOO_TAG
FROM odoo:${ODOO_VERSION} FROM odoo:${ODOO_TAG}
# Switch to root user # Switch to root user
USER root USER root
# Receive ARGs from docker-compose.yml & convert them into ENVs # Receive ARGs from docker-compose.yml & convert them into ENVs
ARG ODOO_TAG
ARG ROOT_PATH ARG ROOT_PATH
ARG LOG_PATH ARG LOG_PATH
ARG GITHUB_USER ARG GITHUB_USER
ARG GITHUB_ACCESS_TOKEN ARG GITHUB_ACCESS_TOKEN
ARG ENTERPRISE_REPO
ARG ENTERPRISE_ADDONS ARG ENTERPRISE_ADDONS
ARG ODOO_RC ARG ODOO_RC
ENV ODOO_VERSION=${ODOO_VERSION} \ ENV ODOO_TAG=${ODOO_TAG} \
LOG_PATH=${LOG_PATH} \ LOG_PATH=${LOG_PATH} \
GITHUB_USER=${GITHUB_USER} \ GITHUB_USER=${GITHUB_USER} \
GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} \ GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} \
ENTERPRISE_REPO=${ENTERPRISE_REPO} \
ENTERPRISE_ADDONS=${ENTERPRISE_ADDONS} \ ENTERPRISE_ADDONS=${ENTERPRISE_ADDONS} \
ODOO_RC=${ODOO_RC} ODOO_RC=${ODOO_RC}
@@ -53,7 +52,7 @@ RUN mkdir -p ${ENTERPRISE_ADDONS} && \
# Clone Enterprise addons if user and token are present # Clone Enterprise addons if user and token are present
RUN if [ -n "$GITHUB_USER" ] && [ -n "$GITHUB_ACCESS_TOKEN" ]; then \ RUN if [ -n "$GITHUB_USER" ] && [ -n "$GITHUB_ACCESS_TOKEN" ]; then \
git clone ${ENTERPRISE_REPO} ${ENTERPRISE_ADDONS} --depth 1 --branch ${ODOO_VERSION} --single-branch --no-tags; \ git clone https://${GITHUB_USER}:${GITHUB_ACCESS_TOKEN}@github.com/odoo/enterprise.git ${ENTERPRISE_ADDONS} --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags; \
fi fi
#---------------------# #---------------------#

View File

@@ -12,62 +12,63 @@ case "$1" in
wait-for-psql.py --db_host ${DB_HOST} --db_port ${DB_PORT} --db_user ${DB_USER} --db_password ${DB_PASSWORD} --timeout=30 wait-for-psql.py --db_host ${DB_HOST} --db_port ${DB_PORT} --db_user ${DB_USER} --db_password ${DB_PASSWORD} --timeout=30
if [ ${APP_ENV} = 'fresh' ] || [ ${APP_ENV} = 'restore' ]; then if [ ${APP_ENV} = 'fresh' ] || [ ${APP_ENV} = 'restore' ]; then
echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 # Ideal for a fresh install or restore a production database.
echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --log-level=${LOG_LEVEL} --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200
exec odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 exec odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200
fi fi
if [ ${APP_ENV} = 'full' ] ; then if [ ${APP_ENV} = 'full' ] ; then
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --max-cron-threads=${MAX_CRON_THREADS} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all # Ideal for initializing a fresh database with a huge amount of addons.
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update= --load=${SERVER_WIDE_MODULES} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --max-cron-threads=${MAX_CRON_THREADS} --limit-time-cpu=3600 --limit-time-real=7200
exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --max-cron-threads=${MAX_CRON_THREADS} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all exec odoo --config ${ODOO_RC} --update= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200
fi fi
if [ ${APP_ENV} = 'local' ] ; then if [ ${APP_ENV} = 'local' ] ; then
# Automagically update the addons you are currently working on. # Listens to all .env variables mapped into odoo.conf file.
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --workers=${WORKERS} --dev=${DEV_MODE} echo odoo --config ${ODOO_RC}
exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --workers=${WORKERS} --dev=${DEV_MODE} exec odoo --config ${ODOO_RC}
fi fi
if [ ${APP_ENV} = 'debug' ] ; then if [ ${APP_ENV} = 'debug' ] ; then
# Automagically update the addons you are currently working on. # Same as local but you can debug you custom addons with your code editor (VSCode).
echo /usr/bin/python3 -m debugpy --listen ${DEBUG_INTERFACE}:${DEBUG_PORT} ${DEBUG_PATH} --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --workers=${WORKERS} --dev=${DEV_MODE} echo debugpy odoo --config ${ODOO_RC}
exec /usr/bin/python3 -m debugpy --listen ${DEBUG_INTERFACE}:${DEBUG_PORT} ${DEBUG_PATH} --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --workers=${WORKERS} --dev=${DEV_MODE} exec /usr/bin/python3 -m debugpy --listen ${DEBUG_INTERFACE}:${DEBUG_PORT} ${DEBUG_PATH} --config ${ODOO_RC}
fi fi
if [ ${APP_ENV} = 'testing' ] ; then if [ ${APP_ENV} = 'testing' ] ; then
# Runs the tests in a 'test_*' database for the addons you are currently working on via test tags. # Initializies a fresh 'test_*' database, installs the addons to test, and runs tests you specify in the test tags.
echo odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --without-demo= --workers=0 --stop-after-init echo odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --load=${SERVER_WIDE_MODULES} --log-level=${LOG_LEVEL} --without-demo= --workers=0 --stop-after-init
exec odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --without-demo= --workers=0 --stop-after-init exec odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --without-demo= --workers=0 --stop-after-init
fi fi
if [ ${APP_ENV} = 'staging' ] ; then if [ ${APP_ENV} = 'staging' ] ; then
# Automagically upgrade all addons and install new ones. # Automagically upgrade all addons and install new ones. Ideal for deployment process.
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200
exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all exec odoo --config ${ODOO_RC} --update=all --without-demo=all --workers=0 --limit-time-cpu=3600 --limit-time-real=7200
fi fi
if [ ${APP_ENV} = 'production' ] ; then if [ ${APP_ENV} = 'production' ] ; then
# Bring up Odoo ready for production. # Bring up Odoo ready for production.
echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --workers=${WORKERS} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language= --without-demo=all --dev=False echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --workers=${WORKERS} --log-level=${LOG_LEVEL} --load-language= --without-demo=all --dev=
exec odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --workers=${WORKERS} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language= --without-demo=all --dev=False exec odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --without-demo=all --dev=
fi fi
fi fi
;; ;;
-*) -*)
# TODO: check which cases end up here.
wait-for-psql.py --db_host ${DB_HOST} --db_port ${DB_PORT} --db_user ${DB_USER} --db_password ${DB_PASSWORD} --timeout=30 wait-for-psql.py --db_host ${DB_HOST} --db_port ${DB_PORT} --db_user ${DB_USER} --db_password ${DB_PASSWORD} --timeout=30
echo odoo --config ${ODOO_RC} echo odoo --config ${ODOO_RC}
exec odoo --config ${ODOO_RC} exec odoo --config ${ODOO_RC}
;; ;;
*) *)
# TODO: check which cases end up here.
echo "$@" echo "$@"
exec "$@" exec "$@"
esac esac

View File

@@ -1,4 +1,5 @@
FROM postgres:15.3 ARG POSTGRES_TAG
FROM postgres:${POSTGRES_TAG}
#------------------------# #------------------------#
# APT Dependencies # # APT Dependencies #