Merge pull request #8 from odoocker/feature/enable-or-disable-features

Yhael | Feature | Enable or disable features
This commit is contained in:
Yhael S
2023-10-20 00:39:10 -06:00
committed by GitHub
9 changed files with 204 additions and 118 deletions

View File

@@ -5,12 +5,16 @@
APP_ENV=local
INIT=
UPDATE=
LOAD=base,web,session_redis,attachment_s3,sentry
LOAD=base,web
ROOT_PATH=/usr/lib/python3/dist-packages/odoo
WORKERS=2
DEV_MODE=reload,xml
DOMAIN=erp.odoocker.test
# Services
SERVICES=odoo,nginx,proxy,postgres
PROJECT_NAME=odoocker
# Enterprise
GITHUB_USER=
GITHUB_ACCESS_TOKEN=
@@ -19,7 +23,7 @@ GITHUB_ACCESS_TOKEN=
ADMIN_PASSWD=odoo
DB_HOST=postgres
DB_PORT=5432
DB_NAME=odoocker
DB_NAME=
DB_USER=odoo
DB_PASSWORD=odoo
LOAD_LANGUAGE=
@@ -36,7 +40,7 @@ LOG_LEVEL=info
# Additional logs
LOG_HANDLER_LEVEL=INFO
# Sentry
SENTRY_DSN=https://84799fb74edc4053aa3368aec3c2cb89@o4504596558577664.ingest.sentry.io/4504596563230720
SENTRY_DSN=
SENTRY_ENABLED=true
SENTRY_LOGGING_LEVEL=warn
SENTRY_EXCLUDE_LOGGERS=
@@ -92,7 +96,7 @@ AWS_HOST=http://s3:${S3_API_PORT}
AWS_REGION=
AWS_ACCESS_KEY_ID=myaccesskey
AWS_SECRET_ACCESS_KEY=mysecretkey
AWS_BUCKETNAME=odoocker
AWS_BUCKETNAME=${PROJECT_NAME}-{db}
# PgAdmin
PGADMIN_DOMAIN=pgadmin.odoocker.test
@@ -111,9 +115,27 @@ PGADMIN_CONFIG_SERVER_MODE=True
# Project Configurations #
#------------------------------#
# Docker
PROJECT_NAME=odoocker
PROJECT_NAME=${PROJECT_NAME}
SUPPORT_EMAIL=mail@example.com
# Service configuration
USE_REDIS=true
USE_S3=true
USE_SENTRY=false
# Which services are going to be brought up
COMPOSE_PROFILES=${SERVICES}
# Service profiles
ODOO_PROFILES="odoo"
POSTGRES_PROFILES="postgres"
NGINX_PROFILES="nginx"
NGINX_PROXY_PROFILES="proxy"
ACME_COMPANION_PROFILES="acme"
KEYDB_PROFILES="keydb"
MINIO_PROFILES="minio"
PGADMIN_PROFILES="pgadmin"
# Containers' Tags
ODOO_TAG=16.0
POSTGRES_TAG=16.0
@@ -124,7 +146,7 @@ NGINX_PROXY_TAG=1.3.1
ACME_COMPANION_TAG=2.2.8
PGADMIN_TAG=7.6
# Custom paths
# Odoocker paths
COMMUNITY_ADDONS=${ROOT_PATH}/addons
ENTERPRISE_ADDONS=${ROOT_PATH}/enterprise
THIRD_PARTY_ADDONS=${ROOT_PATH}/third-party-addons
@@ -302,6 +324,9 @@ CORS_ALLOWED_DOMAIN=${CORS_ALLOWED_DOMAIN}
#----------------------#
# ACME Companion #
#----------------------#
# For prod use: https://acme-v02.api.letsencrypt.org/directory
ACME_CA_URI=https://acme-staging-v02.api.letsencrypt.org/directory
CERTS_UPDATE_INTERVAL=3600
DEFAULT_EMAIL=${SUPPORT_EMAIL}
#-------------#

View File

@@ -19,3 +19,4 @@ services:
restart: 'no'
ports:
- 80:80
- 443:443

View File

@@ -1,38 +1,22 @@
services:
odoo:
restart: unless-stopped
restart: 'no'
ports:
- 127.0.0.1:8069:8069
- 127.0.0.1:8070:8070
- 127.0.0.1:8071:8071
- 127.0.0.1:8072:8072
postgres:
restart: unless-stopped
restart: 'no'
ports:
- 127.0.0.1:5432:5432
nginx:
restart: 'no'
nginx-proxy:
restart: unless-stopped
restart: 'no'
ports:
- 80:80
- 443:443
letsencrypt:
image: nginxproxy/acme-companion:${ACME_COMPANION_TAG}
depends_on:
- nginx-proxy
restart: unless-stopped
volumes_from:
- nginx-proxy:rw
volumes:
- certs:${NGINX_CERTS}:rw
- acme:${NGINX_ACME}
- ${DOCKER_SOCK}:${DOCKER_SOCK}:ro
environment:
- DEFAULT_EMAIL
networks:
- internal
volumes:
acme:
certs:

View File

@@ -1,45 +0,0 @@
services:
pgadmin:
build:
context: ./
dockerfile: ./pgadmin/Dockerfile
args:
- PGADMIN_TAG
depends_on:
- postgres
restart: 'no'
expose:
- 80
volumes:
- pgadmin-data:${PGADMIN_DATA}
environment:
- PGADMIN_DEFAULT_EMAIL
- PGADMIN_DEFAULT_PASSWORD
- VIRTUAL_HOST=${PGADMIN_VIRTUAL_HOST}
- LETSENCRYPT_HOST=${PGADMIN_LETSENCRYPT_HOST}
- LETSENCRYPT_EMAIL=${PGADMIN_LETSENCRYPT_EMAIL}
- PGADMIN_CONFIG_APP_NAME
- PGADMIN_CONFIG_CONFIG_DATABASE_CONNECTION_POOL_SIZE
- PGADMIN_CONFIG_SERVER_MODE
- PGADMIN_CONFIG_DEFAULT_SERVER
- PGADMIN_CONFIG_DEFAULT_SERVER_PORT
- PGADMIN_CONFIG_PASSWORD_LENGTH_MIN
- PGADMIN_CONFIG_MAX_SESSION_IDLE_TIME
- PGADMIN_CONFIG_CONFIG_DATABASE_URI
- PGADMIN_CONFIG_ALLOW_SAVE_PASSWORD
- PGADMIN_CONFIG_MAX_QUERY_HIST_STORED
- PGADMIN_CONFIG_MAIL_SERVER
- PGADMIN_CONFIG_MAIL_PORT
- PGADMIN_CONFIG_MAIL_USE_SSL
- PGADMIN_CONFIG_MAIL_USE_TLS
- PGADMIN_CONFIG_MAIL_USERNAME
- PGADMIN_CONFIG_MAIL_PASSWORD
- PGADMIN_CONFIG_MAIL_DEBUG
- PGADMIN_CONFIG_SECURITY_EMAIL_SENDER
- PGADMIN_CONFIG_ALLOW_SAVE_TUNNEL_PASSWORD
- PGADMIN_CONFIG_MAX_LOGIN_ATTEMPTS
networks:
- internal
volumes:
pgadmin-data:

View File

@@ -1,3 +1,5 @@
services:
odoo:
build:
@@ -12,8 +14,9 @@ services:
- ENTERPRISE_ADDONS
- THIRD_PARTY_ADDONS
- LOG_PATH
depends_on:
- postgres
- USE_REDIS
- USE_S3
- USE_SENTRY
tty: true
volumes:
- odoo-data:${DATA_DIR}
@@ -27,6 +30,9 @@ services:
- PASSWORD=${DB_PASSWORD}
- ODOO_TAG
- ODOO_RC
- USE_REDIS
- USE_S3
- USE_SENTRY
- THIRD_PARTY_ADDONS
- ODOO_SESSION_REDIS
- ODOO_SESSION_REDIS_HOST
@@ -46,6 +52,7 @@ services:
- AWS_BUCKETNAME
networks:
- internal
profiles: [$ODOO_PROFILES]
postgres:
build:
@@ -71,34 +78,7 @@ services:
- PGADMIN_DB_PASSWORD
networks:
- internal
redis:
image: eqalpha/keydb:${KEYDB_TAG}
platform: linux/amd64
ports:
- ${KEYDB_PORT}:${KEYDB_PORT}
restart: unless-stopped
volumes:
- redis-data:${KEYDB_DATA}
networks:
- internal
s3:
image: minio/minio:${MINIO_TAG}
environment:
- MINIO_ROOT_USER
- MINIO_ROOT_PASSWORD
- MINIO_BROWSER_REDIRECT_URL
- VIRTUAL_HOST=${MINIO_VIRTUAL_HOST}
- VIRTUAL_PORT=${MINIO_CONSOLE_PORT}
command: server ${MINIO_DATA} --console-address ":${MINIO_CONSOLE_PORT}"
volumes:
- s3-data:${MINIO_DATA}
ports:
- ${MINIO_API_PORT}:${MINIO_API_PORT}
- ${MINIO_CONSOLE_PORT}:${MINIO_CONSOLE_PORT}
networks:
- internal
profiles: [$POSTGRES_PROFILES]
nginx:
image: nginx:${NGINX_TAG}
@@ -118,6 +98,7 @@ services:
- CORS_ALLOWED_DOMAIN
networks:
- internal
profiles: [$NGINX_PROFILES]
nginx-proxy:
image: nginxproxy/nginx-proxy:${NGINX_PROXY_TAG}
@@ -128,24 +109,119 @@ services:
volumes:
- ./nginx-proxy/nginx.conf:${NGINX_CONF}
- ./nginx-proxy/cors.conf:${NGINX_PROXY_CORS_CONF}
- certs:${NGINX_CERTS}:ro
- vhost:${NGINX_VHOST}
- html:${NGINX_HTML}
- vhost:${NGINX_VHOST}
- certs:${NGINX_CERTS}:ro
- ${DOCKER_SOCK}:${TEMP_DOCKER_SOCK}:ro
environment:
- TRUST_DOWNSTREAM_PROXY
- CORS_ALLOWED_DOMAIN
networks:
- internal
profiles: [$NGINX_PROXY_PROFILES]
redis:
image: eqalpha/keydb:${KEYDB_TAG}
platform: linux/amd64
ports:
- ${KEYDB_PORT}:${KEYDB_PORT}
restart: unless-stopped
volumes:
- redis-data:${KEYDB_DATA}
networks:
- internal
profiles: [$KEYDB_PROFILES]
s3:
image: minio/minio:${MINIO_TAG}
environment:
- MINIO_ROOT_USER
- MINIO_ROOT_PASSWORD
- MINIO_BROWSER_REDIRECT_URL
- VIRTUAL_HOST=${MINIO_VIRTUAL_HOST}
- VIRTUAL_PORT=${MINIO_CONSOLE_PORT}
command: server ${MINIO_DATA} --console-address ":${MINIO_CONSOLE_PORT}"
volumes:
- s3-data:${MINIO_DATA}
ports:
- ${MINIO_API_PORT}:${MINIO_API_PORT}
- ${MINIO_CONSOLE_PORT}:${MINIO_CONSOLE_PORT}
networks:
- internal
profiles: [$MINIO_PROFILES]
letsencrypt:
image: nginxproxy/acme-companion:${ACME_COMPANION_TAG}
depends_on:
- nginx-proxy
restart: unless-stopped
volumes_from:
- nginx-proxy:rw
volumes:
- certs:${NGINX_CERTS}:rw
- acme:${NGINX_ACME}
- ${DOCKER_SOCK}:${DOCKER_SOCK}:ro
environment:
- ACME_CA_URI
- CERTS_UPDATE_INTERVAL
- DEFAULT_EMAIL
networks:
- internal
profiles: [$ACME_COMPANION_PROFILES]
pgadmin:
build:
context: ./
dockerfile: ./pgadmin/Dockerfile
args:
- PGADMIN_TAG
depends_on:
- postgres
restart: 'no'
expose:
- 80
volumes:
- pgadmin-data:${PGADMIN_DATA}
environment:
- PGADMIN_DEFAULT_EMAIL
- PGADMIN_DEFAULT_PASSWORD
- VIRTUAL_HOST=${PGADMIN_VIRTUAL_HOST}
- LETSENCRYPT_HOST=${PGADMIN_LETSENCRYPT_HOST}
- LETSENCRYPT_EMAIL=${PGADMIN_LETSENCRYPT_EMAIL}
- PGADMIN_CONFIG_APP_NAME
- PGADMIN_CONFIG_CONFIG_DATABASE_CONNECTION_POOL_SIZE
- PGADMIN_CONFIG_SERVER_MODE
- PGADMIN_CONFIG_DEFAULT_SERVER
- PGADMIN_CONFIG_DEFAULT_SERVER_PORT
- PGADMIN_CONFIG_PASSWORD_LENGTH_MIN
- PGADMIN_CONFIG_MAX_SESSION_IDLE_TIME
- PGADMIN_CONFIG_CONFIG_DATABASE_URI
- PGADMIN_CONFIG_ALLOW_SAVE_PASSWORD
- PGADMIN_CONFIG_MAX_QUERY_HIST_STORED
- PGADMIN_CONFIG_MAIL_SERVER
- PGADMIN_CONFIG_MAIL_PORT
- PGADMIN_CONFIG_MAIL_USE_SSL
- PGADMIN_CONFIG_MAIL_USE_TLS
- PGADMIN_CONFIG_MAIL_USERNAME
- PGADMIN_CONFIG_MAIL_PASSWORD
- PGADMIN_CONFIG_MAIL_DEBUG
- PGADMIN_CONFIG_SECURITY_EMAIL_SENDER
- PGADMIN_CONFIG_ALLOW_SAVE_TUNNEL_PASSWORD
- PGADMIN_CONFIG_MAX_LOGIN_ATTEMPTS
networks:
- internal
profiles: [$PGADMIN_PROFILES]
volumes:
odoo-data:
pg-data:
redis-data:
s3-data:
certs:
vhost:
pgadmin-data:
html:
vhost:
certs:
acme:
networks:
internal:

View File

@@ -16,6 +16,9 @@ ARG GITHUB_ACCESS_TOKEN
ARG ENTERPRISE_ADDONS
ARG THIRD_PARTY_ADDONS
ARG ODOO_RC
ARG USE_REDIS
ARG USE_S3
ARG USE_SENTRY
ENV ODOO_TAG=${ODOO_TAG} \
LOG_PATH=${LOG_PATH} \
@@ -23,7 +26,10 @@ ENV ODOO_TAG=${ODOO_TAG} \
GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} \
ENTERPRISE_ADDONS=${ENTERPRISE_ADDONS} \
THIRD_PARTY_ADDONS=${THIRD_PARTY_ADDONS} \
ODOO_RC=${ODOO_RC}
ODOO_RC=${ODOO_RC} \
USE_REDIS=${USE_REDIS} \
USE_S3=${USE_S3} \
USE_SENTRY=${USE_SENTRY}
#------------------------#
# APT Dependencies #

View File

@@ -14,6 +14,22 @@ while IFS='=' read -r key value || [[ -n $key ]]; do
eval "$key=\"$value\""
done < .env
# Check the USE_REDIS to add base_attachment_object_storage & session_redis to LOAD variable
if [[ $USE_REDIS == "true" ]]; then
LOAD+=",session_redis"
fi
# Check the USE_REDIS to add attachment_s3 to LOAD variable
if [[ $USE_S3 == "true" ]]; then
LOAD+=",base_attachment_object_storage"
LOAD+=",attachment_s3"
fi
# Check the USE_REDIS to add sentry to LOAD variable
if [[ $USE_SENTRY == "true" ]]; then
LOAD+=",sentry"
fi
case "$1" in
-- | odoo)
shift
@@ -25,14 +41,14 @@ case "$1" in
if [ ${APP_ENV} = 'fresh' ] || [ ${APP_ENV} = 'restore' ]; then
# 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
echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${LOAD} --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
if [ ${APP_ENV} = 'local' ] ; then
# Listens to all .env variables mapped into odoo.conf file.
echo odoo --config ${ODOO_RC}
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${LOAD} --workers=${WORKERS} --log-level=${LOG_LEVEL} --dev=${DEV_MODE}
exec odoo --config ${ODOO_RC}
fi
@@ -46,21 +62,21 @@ case "$1" in
if [ ${APP_ENV} = 'testing' ] ; then
# 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-level=${LOG_LEVEL} --without-demo= --workers=0 --dev= --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=${LOAD} --log-level=${LOG_LEVEL} --without-demo= --workers=0 --dev= --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 --dev= --stop-after-init
fi
if [ ${APP_ENV} = 'staging' ] ; then
# 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-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200 --dev=
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${LOAD} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200 --dev=
exec odoo --config ${ODOO_RC} --update=all --without-demo=all --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 --dev=
fi
if [ ${APP_ENV} = 'production' ] ; then
# Bring up Odoo ready for production.
echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --workers=${WORKERS} --log-level=${LOG_LEVEL} --load-language= --without-demo=all --dev=
echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${LOAD} --workers=${WORKERS} --log-level=${LOG_LEVEL} --load-language= --without-demo=all --dev=
exec odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --without-demo=all --dev=
fi

View File

@@ -20,6 +20,22 @@ while IFS='=' read -r key value || [[ -n $key ]]; do
export "$key=$value"
done < .env
# Check the USE_REDIS to add base_attachment_object_storage & session_redis to LOAD variable
if [[ $USE_REDIS == "true" ]]; then
LOAD+=",session_redis"
fi
# Check the USE_REDIS to add attachment_s3 to LOAD variable
if [[ $USE_S3 == "true" ]]; then
LOAD+=",base_attachment_object_storage"
LOAD+=",attachment_s3"
fi
# Check the USE_REDIS to add sentry to LOAD variable
if [[ $USE_SENTRY == "true" ]]; then
LOAD+=",sentry"
fi
# Copy the example conf to the destination to start replacing the variables
cp "$TEMPLATE_CONF" "$ODOO_RC"

View File

@@ -2,16 +2,23 @@
set -e
# Check if the repository directory exists
if [ ! -d "odoo-cloud-platform" ]; then
# Check if the repository directory exists and either Redis or S3 is to be used
if [[ ${USE_REDIS} == "true" || ${USE_S3} == "true" ]]; then
git clone https://github.com/odoocker/odoo-cloud-platform.git --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags;
fi
if [[ ${USE_REDIS} == "true" ]]; then
cp -r odoo-cloud-platform/session_redis ${THIRD_PARTY_ADDONS}/session_redis
fi
# Check the USE_S3 variable to decide whether to copy S3 directories
if [[ ${USE_S3} == "true" ]]; then
cp -r odoo-cloud-platform/base_attachment_object_storage ${THIRD_PARTY_ADDONS}/base_attachment_object_storage
cp -r odoo-cloud-platform/attachment_s3 ${THIRD_PARTY_ADDONS}/attachment_s3
fi
# Check if the repository directory exists
if [ ! -d "server-tools" ]; then
# Check if the repository directory exists and Sentry is to be used
if [[ ${USE_SENTRY} == "true" ]]; then
git clone https://github.com/odoocker/server-tools.git --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags;
cp -r server-tools/sentry ${THIRD_PARTY_ADDONS}/sentry
fi