first commit

This commit is contained in:
Yhael S
2023-04-19 14:27:50 -05:00
commit 6b2571d805
19 changed files with 1505 additions and 0 deletions

194
.env.example Normal file
View File

@@ -0,0 +1,194 @@
#--------------------------#
# Main Configuration #
#--------------------------#
APP_ENV=fresh
ADDONS_TO_UPDATE=
ADDONS_TO_INSTALL=
DB_NAME=odoo
DB_USER=odoo
DB_PASSWORD=odoo
LOG_LEVEL=info
LOG_HANDLER="[':INFO']"
SMTP_SERVER=
SMTP_PORT=25
SMTP_SSL=
SMTP_USER=
SMTP_PASSWORD=
EMAIL_FROM=
ADMIN_PASSWD=odoo
DOMAIN=erp.odoo.test
PGADMIN_DOMAIN=pgadmin.odoo.test
PGADMIN_PASSWORD=${DB_PASSWORD}
LOAD_LANGUAGE=en_US
DEV_MODE=False
#------------------------------#
# Project Configurations #
#------------------------------#
PROJECT_NAME=odoocker
DOMAIN=${DOMAIN}
SUPPORT_EMAIL=example@mail.com
#------------#
# Odoo #
#------------#
# Options not exposed on the command line.
ADMIN_PASSWD=${ADMIN_PASSWD}
CSV_INTERNAL_SEP=,
PUBLISHER_WARRANTY_URL=http://services.openerp.com/publisher-warranty/
ROOT_PATH=/usr/lib/python3/dist-packages/odoo
REPORTGZ=False
WEBSOCKET_KEEP_ALIVE_TIMEOUT=3600
WEBSOCKET_RATE_LIMIT_BURST=10
WEBSOCKET_RATE_LIMIT_DELAY=0.2
# Custom paths
COMMUNITY_ADDONS=${ROOT_PATH}/addons
ENTERPRISE_ADDONS=${ROOT_PATH}/enterprise
EXTRA_ADDONS=${ROOT_PATH}/extra-addons
CUSTOM_ADDONS=${ROOT_PATH}/custom-addons
# Server startup config
ODOO_RC=/etc/odoo/odoo.conf
SAVE=False
INIT=${ADDONS_TO_INSTALL}
UPDATE=${ADDONS_TO_UPDATE}
DEMO=False
WITHOUT_DEMO=all
IMPORT_PARTIAL=
PIDFILE=
ADDONS_PATH=${COMMUNITY_ADDONS},${ENTERPRISE_ADDONS},${EXTRA_ADDONS},${CUSTOM_ADDONS}
UPGRADE_PATH=
SERVER_WIDE_MODULES=base,web
DATA_DIR=/var/lib/odoo
# HTTP
HTTP_INTERFACE=0.0.0.0
HTTP_PORT=8069
LONGPOLLING_PORT=8072
HTTP_ENABLE=True
PROXY_MODE=True
X_SENDFILE=False
# Testing
TEST_FILE=False
TEST_ENABLE=False
TEST_TAGS=None
SCREENCASTS=None
SCREENSHOTS=/tmp/odoo_tests
# Logging
LOGFILE=
SYSLOG=False
LOG_HANDLER="[':INFO']"
LOG_DB=False
LOG_DB_LEVEL=info
LOG_LEVEL=info
# Email
EMAIL_FROM=${EMAIL_FROM}
FROM_FILTER=False
SMTP_SERVER=${SMTP_SERVER}
SMTP_PORT=${SMTP_PORT}
SMTP_SSL=${SMTP_SSL}
SMTP_USER=${SMTP_USER}
SMTP_PASSWORD=${SMTP_PASSWORD}
SMTP_SSL_CERTIFICATE_FILENAME=False
SMTP_SSL_PRIVATE_KEY_FILENAME=False
# DB Group
DB_NAME=${DB_NAME}
DB_USER=${DB_USER}
DB_PASSWORD=${DB_PASSWORD}
PG_PATH=
DB_HOST=postgres
DB_PORT=5432
DB_SSLMODE=prefer
DB_MAXCONN=64
DB_TEMPLATE=unaccent_template
# Internationalisation options
LOAD_LANGUAGE=${LOAD_LANGUAGE}
LANGUAGE=
TRANSLATE_OUT=
TRANSLATE_IN=
OVERWRITE_EXISTING_TRANSLATIONS=False
TRANSLATE_MODULES="['all']"
# Security
LIST_DB=True
# WEB
DBFILTER=.*
# Advanced options
DEV_MODE=${DEV_MODE}
SHELL_INTERFACE=ptpython
STOP_AFTER_INIT=False
OSV_MEMORY_COUNT_LIMIT=False
TRANSIENT_AGE_LIMIT=1.0
MAX_CRON_THREADS=2
UNACCENT=True
GEOIP_DATABASE=/usr/share/GeoIP/GeoLite2-City.mmdb
WORKERS=0
LIMIT_MEMORY_SOFT=2147483648
LIMIT_MEMORY_HARD=2684354560
LIMIT_TIME_CPU=120
LIMIT_TIME_REAL=240
LIMIT_TIME_REAL_CRON=600
LIMIT_REQUEST=8192
INSTALLED_MODULES=
#--------------#
# Docker #
#--------------#
COMPOSE_PROJECT_NAME=${PROJECT_NAME}
DOCKER_SOCK=/var/run/docker.sock
TEMP_DOCKER_SOCK=/tmp/docker.sock
#----------------#
# Postgres #
#----------------#
POSTGRES_HOST=${DB_HOST}
POSTGRES_PORT=${DB_PORT}
POSTGRES_DB=postgres
POSTGRES_USER=${DB_USER}
POSTGRES_PASSWORD=${DB_PASSWORD}
PGDATA=/var/lib/postgresql/data/${PROJECT_NAME}
#-------------#
# Nginx #
#-------------#
NGINX_CONF=/etc/nginx/nginx.conf
NGINX_DEFAULT_CONF=/etc/nginx/conf.d/default.conf
VIRTUAL_HOST=${DOMAIN}
LETSENCRYPT_HOST=${DOMAIN}
LETSENCRYPT_EMAIL=${SUPPORT_EMAIL}
CORS_ALLOWED_DOMAIN="'https://sub.domain.com'"
#-------------#
# PgAdmin #
#-------------#
PGADMIN_DATA=/var/lib/pgadmin
PGADMIN_VIRTUAL_HOST=${PGADMIN_DOMAIN}
PGADMIN_DEFAULT_EMAIL=${SUPPORT_EMAIL}
PGADMIN_DEFAULT_PASSWORD=${PGADMIN_PASSWORD}
PGADMIN_LETSENCRYPT_HOST=${PGADMIN_DOMAIN}
LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
#-------------------#
# Nginx Proxy #
#-------------------#
NGINX_CERTS=/etc/nginx/certs
NGINX_VHOST=/etc/nginx/vhost.d
NGINX_HTML=/usr/share/nginx/html
NGINX_ACME=/etc/acme.sh
TRUST_DOWNSTREAM_PROXY=true
NGINX_PROXY_CORS_CONF=/etc/nginx/cors.conf
CORS_ALLOWED_DOMAIN=${CORS_ALLOWED_DOMAIN}
#----------------------#
# ACME Companion #
#----------------------#
DEFAULT_EMAIL=${SUPPORT_EMAIL}

11
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,11 @@
## :rocket: Deployment
- `ADDONS_TO_INSTALL="my_custom_addon"`
- `ADDONS_TO_UPGRADE="contacts,sale"`
## :memo: Changes
**Change 1: *Title***
- In detail, explain what changes were made.
*Add links and screenshots*
<hr>

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
# Ignores the main configuration file.
/.env
# Ignores the docker compose local or production environment.
docker-compose.override.yml

221
README.md Normal file
View File

@@ -0,0 +1,221 @@
# Setup
```
1. Clone the repository:
```
git clone git@github.com:yhaelopez/odoocker.git
```
2. Copy the `.env.example` and `docker-compose.override.local.yml`
```
cp .env.example .env && cp docker-compose.override.local.yml docker-compose.override.yml
```
3. Manually add entry to your `hosts` file as below (Local)
```
echo '127.0.0.1 erp.odoo.test' | sudo tee -a /etc/hosts
echo '127.0.0.1 pgadmin.odoo.test' | sudo tee -a /etc/hosts
```
- For Windows, go to `C:\Windows\System32\drivers\etc\`, and add this line:
```
127.0.0.1 erp.odoo.test
127.0.0.1 pgadmin.odoo.test
In order to understand how each environment works, take a look at `odoo/entrypoint.sh`.
```
Master Password: odoo
```
## Fresh Environment
This environment will have no database created.
The `env.example` is ready for this stage, no modifications are needed on `.env`.
1. Make sure `APP_ENV=fresh`.
2. Run
```
docker-compose up --build -d && docker-compose logs -f odoo
```
3. Navigate to the `DOMAIN` in your browser.
4. Create Database form will be displayed.
5. Create Fresh DB.
6. Stop the Odoo container:
```
docker-compose stop odoo
```
7. Set [`Local`](https://github.com/yhaelopez/odoocker#local-environment) environment.
## Full Environment
This environment will initialize a database with `DB_NAME` and install the `INSTALLED_MODULES`.
This allows us to have a fresh database will all modules installed in production.
1. Make sure `APP_ENV=full`.
2. Make sure `DB_NAME=odoo` or whatever name you want.
3. Run
```
docker-compose up -d --build && docker-compose logs -f odoo
```
4. Navigate to the `DOMAIN` in your browser.
5. Log in using the default credentials
```
Email: admin
Password: admin
```
6. Stop the Odoo container:
```
docker-compose stop odoo
```
7. Set [`Local`](https://github.com/yhaelopez/odoocker#local-environment) environment.
## Restore Environment
This environment will have no database created and it's ready to make an import on the production database.
1. Set `APP_ENV=restore`.
2. Run:
```
docker-compose up --build -d && docker-compose logs -f odoo
```
3. Navigate to the `DOMAIN` in your browser & Restore the production database
4. Stop the Odoo container:
```
docker-compose stop odoo
```
5. Set [`Local`](https://github.com/yhaelopez/odoocker#local-environment) environment.
--- If you are in a production server:
6. Set [`Staging`](https://github.com/yhaelopez/odoocker#staging-environment) environment.
7. Stop the Odoo container:
```
docker-compose stop odoo
```
8. Run the [`Production`](https://github.com/yhaelopez/odoocker#production-environment) environment.
## Local Environment
This environment will help us install / update the specific modules we are working on.
It's recommended to use this environment after [`Fresh`](https://github.com/yhaelopez/odoocker#fresh-environment), [`Full`](https://github.com/yhaelopez/odoocker#full-environment) or [`Restore`](https://github.com/yhaelopez/odoocker#fresh-environment) environments are run.
1. Make sure `APP_ENV=local`.
2. Make sure `DB_NAME` is set.
3. Set `ADDONS_TO_UPDATE=module1,module2,module3`.
4. Run:
```
docker-compose up --build -d odoo && docker-compose logs -f odoo
```
5. Navigate to the `DOMAIN` in your browser.
6. Start coding!
7. Any change you make to your packages, run:
```
docker-compose restart odoo && docker-compose logs -f odoo
```
- If you think your package is not being updated, run:
```
docker-compose up --build -d odoo && docker-compose logs -f odoo
```
8. Any time you add a new addon to `ADDONS_TO_UPDATE` re-run last step
## Additional Local Help
### Creating new Odoo Addons
1. Log into the odoo container
```
docker-compose exec -u root odoo
```
2. Navigate to custom addons folder inside the container
```
cd /usr/lib/python3/dist-packages/odoo/custom-addons
```
3. Create new addons running:
```
odoo scaffold <addon_name>
```
- The new addon will be available in the `odoo/custom_addons` folder in this project.
### Using Odoo Shell
1. Log into the odoo container
```
docker-compose exec odoo bash
```
2. Start Odoo shell running:
```
odoo shell --http-port=8071
```
5. Connect to database through any Postgres Database Manager using `localhost` and the `.env` credentials
## Testing Environment (Work in progress...) DO NOT USE
This environment will help us test all modules to ensure a safe deployment.
It's recommneded to use this environment after importing production database in a Fresh environment.
1. Replace `docker-compose.override.yml` with `docker-compose.override.testing.yml`
This will set up the Odoo container will all the packages installed needed to run the tests.
```
cp docker-compose.override.testing.yml docker-compose.override.yml
```
2. Clone Production Database as `test_${DB_NAME}`.
3. Set `APP_ENV=testing`.
4. Set `DB_NAME=test_${DB_NAME}` or whatever db you set before.
5. Run:
```
docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo
```
## Staging
This environment allows us to perfom a full update on all installed modules to test if they all can be upgraded at once.
This also allows to install new packages through `ADDONS_TO_INSTALL`
1. Set `APP_ENV=staging`
2. Set `DB_NAME` to the desired one.
3. Set `ADDONS_TO_INSTALL` if there are any.
5. Run
```
git pull && docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo
```
7. Check Odoo continues to work as expected.
8. Change environment immediatly after finish testing.
**Do not bring down & up again unless you want to perform the whole update again.**
# Production
1. Set `APP_ENV=production`
2. Set prod `DB_NAME`.
3. Set prod `DB_PASSWORD`.
4. Set prod `ADMIN_PASSWD`.
5. Set prod `DOMAIN`.
6. Setup `Fresh` environment
7. Setup `Staging` environment.
8. Repace the `docker-compose.override.yml` with the production one.
This will bring Let's Encrypt (Nginx-Proxy/Acme-Companion) container
```
cp docker-compose.override.production.yml docker-compose.override.yml
```
9. Rebuild the containers
```
docker-compose down && docker-compose up -d --build && docker-compose logs odoo
```
## Deployment
1. Backup the production Databases from `/web/database/manager`.
2. Run
```
sudo apt update && sudo apt upgrade -y
```
- If packages are kept, install them
```
sudo apt install <kept packages>
```
3. Restart the server
```
sudo reboot
```
- Make sure there are no more upgrades or possible kept packages
```
sudo apt update && sudo apt upgrade -y
```
4. Go to the project folder in /home/ubuntu or (~)
```
cd ~/odoocker
```
5. Pull the latest `main` branch changes.
```
git pull origin main
```
6. Set Staging environment
7. Make sure everything continues to work as expected.
8. Set `APP_ENV=production`
9. Take down the containers, pull the latest images from docker hub, and rebuild the containers.
```
docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo
```

View File

@@ -0,0 +1,20 @@
services:
odoo:
restart: 'no'
ports:
- 8069:8069
- 8071:8071
- 8072:8072
postgres:
restart: 'no'
ports:
- 5432:5432
nginx:
restart: 'no'
nginx-proxy:
restart: 'no'
ports:
- 80:80

View File

@@ -0,0 +1,36 @@
services:
odoo:
restart: unless-stopped
ports:
- 127.0.0.1:8069:8069
- 127.0.0.1:8071:8071
- 127.0.0.1:8072:8072
postgres:
ports:
- 127.0.0.1:5432:5432
nginx-proxy:
ports:
- 80:80
- 443:443
letsencrypt:
image: nginxproxy/acme-companion:2.2.4
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:

101
docker-compose.yml Normal file
View File

@@ -0,0 +1,101 @@
services:
odoo:
build:
context: ./
dockerfile: ./odoo/Dockerfile
depends_on:
- postgres
tty: true
volumes:
- data-dir:${DATA_DIR}
- ./odoo/extra-addons:${EXTRA_ADDONS}
- ./odoo/custom-addons:${CUSTOM_ADDONS}
- ./odoo/entrypoint.sh:/entrypoint.sh
- ./odoo/odoorc.sh:/odoorc.sh
env_file:
- ./.env
networks:
- internal
postgres:
build:
context: ./postgres
dockerfile: Dockerfile
restart: unless-stopped
tty: true
volumes:
- pg-data:${PGDATA}
- ./postgres/entrypoint.sh:/docker-entrypoint-initdb.d/entrypoint.sh
environment:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
- PGDATA
networks:
- internal
nginx:
image: nginx:1.23.3
depends_on:
- odoo
restart: unless-stopped
tty: true
expose:
- 80/tcp
volumes:
- ./nginx/nginx.conf:${NGINX_CONF}
- ./nginx/default.conf:${NGINX_DEFAULT_CONF}
environment:
- VIRTUAL_HOST
- LETSENCRYPT_HOST
- LETSENCRYPT_EMAIL
- CORS_ALLOWED_DOMAIN
networks:
- internal
pgadmin:
image: dpage/pgadmin4:6.21
restart: unless-stopped
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
networks:
- internal
nginx-proxy:
image: nginxproxy/nginx-proxy:1.2.0
depends_on:
- nginx
restart: unless-stopped
tty: true
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}
- ${DOCKER_SOCK}:${TEMP_DOCKER_SOCK}:ro
environment:
- TRUST_DOWNSTREAM_PROXY
- CORS_ALLOWED_DOMAIN
networks:
- internal
volumes:
data-dir:
pg-data:
certs:
vhost:
html:
pgadmin-data:
networks:
internal:
driver: bridge

31
nginx-proxy/cors.conf Normal file
View File

@@ -0,0 +1,31 @@
# Allows the usage of $CORS_ALLOWED_DOMAIN
map $http_x_cors_allowed_domain $CORS_ALLOWED_DOMAIN {
default "*";
}
server {
server_name $VIRTUAL_HOST;
listen 443;
location / {
# Set the Access-Control-Allow-Origin header to allow specific domain(s) for CORS
add_header 'Access-Control-Allow-Origin' $CORS_ALLOWED_DOMAIN;
# Specify the allowed HTTP methods for CORS requests
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
# Define the allowed request headers for CORS requests
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
# Specify the response headers that are accessible by the client (browser)
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
# Set the maximum age (in seconds) for the CORS preflight request cache in the client (browser)
add_header 'Access-Control-Max-Age' 1728000;
# Handle CORS preflight (OPTIONS) requests
if ($request_method = 'OPTIONS') {
# Set the response content type and charset for the preflight request
add_header 'Content-Type' 'text/plain; charset=utf-8';
# Set the response content length to 0 for the preflight request
add_header 'Content-Length' 0;
# Return a 204 No Content status for the preflight request
return 204;
}
}
}

37
nginx-proxy/nginx.conf Normal file
View File

@@ -0,0 +1,37 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 10240;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 900;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
send_timeout 900;
client_max_body_size 1024m;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/cors.conf;
}
daemon off;

57
nginx/default.conf Normal file
View File

@@ -0,0 +1,57 @@
# Allows the usage of $CORS_ALLOWED_DOMAIN
map $http_x_cors_allowed_domain $CORS_ALLOWED_DOMAIN {
default "*";
}
server {
client_max_body_size 1024m;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
send_timeout 900;
listen [::]:80;
listen 80;
server_name $VIRTUAL_HOST;
location ~ /.well-known/acme-challenge {
allow all;
root /var/www/html;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://odoo:8069;
# Add CORS headers
add_header 'Access-Control-Allow-Origin' $CORS_ALLOWED_DOMAIN;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
return 204;
}
}
location ~* /web/static/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://odoo:8069;
}
location /longpolling {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://odoo:8072;
}
}

26
nginx/nginx.conf Normal file
View File

@@ -0,0 +1,26 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 900;
include /etc/nginx/conf.d/*.conf;
}

68
odoo/Dockerfile Normal file
View File

@@ -0,0 +1,68 @@
ARG ODOO_VERSION=16.0
FROM odoo:${ODOO_VERSION}
# Switch back to root user
USER root
# Update & Upgrade
RUN apt-get update && apt-get upgrade -y
# Upgrade pip
RUN pip3 install --upgrade pip
# Set Odoo root path
ARG ROOT_PATH=/usr/lib/python3/dist-packages/odoo
#---------------#
# Logging #
#---------------#
# Set Log variables
ARG LOGPATH=/var/log/odoo
ARG LOGFILE=${LOGPATH}/odoo.log
# Create odoo.log file and give permissions.
RUN touch ${LOGFILE} && chown odoo:odoo -R ${LOGPATH}
#-----------------------#
# Odoo Enterprise #
#-----------------------#
# Install git
RUN apt-get install git -y
# Set Github Credentials
ARG GITHUB_USER=yhaelopez
ARG GITHUB_ACCESS_TOKEN=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
ARG ENTERPRISE_REPO=https://${GITHUB_USER}:${GITHUB_ACCESS_TOKEN}@github.com/odoo/enterprise.git
ARG ENTERPRISE_PATH=${ROOT_PATH}/enterprise
# Create Enterprise Path & give permissions
RUN mkdir -p ${ENTERPRISE_PATH} && chown odoo:odoo -R ${ENTERPRISE_PATH}
# Clone Enterprise Repository
RUN git clone ${ENTERPRISE_REPO} ${ROOT_PATH}/enterprise --depth 1 --branch ${ODOO_VERSION} --single-branch --no-tags
#--------------------------------#
# Fix Deprecation Warnings #
#--------------------------------#
#------------------------#
# APT Dependencies #
#------------------------#
#-----------------------#
# PIP Dependencies #
#-----------------------#
#-----------------------#
# Odoo Conf #
#-----------------------#
# Copy environment variables at /
COPY ./.env /
# Copy script to generate odoo.conf
COPY ./odoo/odoorc.sh /
# Generate odoo.conf
RUN /odoorc.sh && chown odoo:odoo ${ODOO_RC}
# Switch back to odoo user
USER odoo

2
odoo/custom-addons/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
# Ignores any __pycache__ folder.
__pycache__

68
odoo/entrypoint.sh Executable file
View File

@@ -0,0 +1,68 @@
#!/bin/bash
set -e
case "$1" in
-- | odoo)
shift
if [[ "$1" == "scaffold" ]] ; then
# Creates new module.
exec odoo "$@"
else
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
echo odoo --config ${ODOO_RC} --database= --update= --init= --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --load-language= --without-demo=True --import-partial=False --log-db= --dev=False
exec odoo --config ${ODOO_RC} --database= --update= --init= --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --load-language= --without-demo=True --import-partial=False --log-db= --dev=False
fi
if [ ${APP_ENV} = 'full' ] ; then
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INSTALLED_MODULES} --update= --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --db-filter= --load-language=${LOAD_LANGUAGE} --without-demo=True --import-partial=False --log-db= --dev=False
exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INSTALLED_MODULES} --update= --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --db-filter= --load-language=${LOAD_LANGUAGE} --without-demo=True --import-partial=False --log-db= --dev=False
fi
if [ ${APP_ENV} = 'local' ] ; then
# Automagically update the addons you are currently working on.
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --update=${UPDATE} --init=${INIT} --load=${SERVER_WIDE_MODULES} --dev=${DEV_MODE}
exec odoo --config ${ODOO_RC} --database=${DB_NAME} --update=${UPDATE} --init=${INIT} --load=${SERVER_WIDE_MODULES} --dev=${DEV_MODE}
fi
if [ ${APP_ENV} = 'testing' ] ; then
# Work in progres... (DO NOT USE)
echo odoo --config ${ODOO_RC} --database=test_${DB_NAME} --db-filter=test_${DB_NAME} --test-enable --test-commit --log-handler=:DEBUG --log-level=debug --workers=0 --init= --update=
exec odoo --config ${ODOO_RC} --database=test_${DB_NAME} --db-filter=test_${DB_NAME} --test-enable --test-commit --log-handler=:DEBUG --log-level=debug --workers=0 --init= --update=
fi
if [ ${APP_ENV} = 'staging' ] ; then
# Automagically install/upgrade all addons
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --db-filter= --load-language=${LOAD_LANGUAGE} --without-demo=True --import-partial=False --log-db= --dev=False
exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --db-filter= --load-language=${LOAD_LANGUAGE} --without-demo=True --import-partial=False --log-db= --dev=False
fi
if [ ${APP_ENV} = 'production' ] ; then
# Bring up Odoo without any addons to install/update.
echo odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --db-filter= --dev=False --import-partial=False --without-demo=True --log-handler=:INFO --log-level=info --log-db= --log-db-level=warning --workers=2 --max-cron-threads=2 --log-level=info --log-handler=:INFO --limit-time-cpu=120 --limit-time-real=240 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --import-partial=False
exec odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --db-filter= --dev=False --import-partial=False --without-demo=True --log-handler=:INFO --log-level=info --log-db= --log-db-level=warning --workers=2 --max-cron-threads=2 --log-level=info --log-handler=:INFO --limit-time-cpu=120 --limit-time-real=240 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --import-partial=False
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
echo odoo --config ${ODOO_RC}
exec odoo --config ${ODOO_RC}
;;
*)
# TODO: check which cases end up here.
echo "$@"
exec "$@"
esac
exit 1

2
odoo/extra-addons/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
# Ignores any __pycache__ folder.
__pycache__

251
odoo/odoo.example.conf Normal file
View File

@@ -0,0 +1,251 @@
[options]
;------------------------------------------;
; Options not exposed on the command line. ;
;------------------------------------------;
admin_passwd=odoo
csv_internal_sep=,
publisher_warranty_url=http://services.openerp.com/publisher-warranty/
root_path=/usr/lib/python3/dist-packages/odoo
reportgz=False
websocket_keep_alive_timeout=3600
websocket_rate_limit_burst=10
websocket_rate_limit_delay=0.2
;-----------------------;
; Server startup config ;
;-----------------------;
; --config | -c
config=/etc/odoo/odoo.conf
; --save
save=False
; --init | -i
init=
; --update | -u
update=
; --without-demo
demo=False
without_demo=all
; --import-partial
import_partial=
; --pidfile
pidfile=
; --addons-path
addons_path=/usr/lib/python3/dist-packages/odoo/addons,/usr/lib/python3/dist-packages/odoo/enterprise,/usr/lib/python3/dist-packages/odoo/extra-addons,/usr/lib/python3/dist-packages/odoo/custom-addons
; --upgrade-path
upgrade_path=
; --load
server_wide_modules=base,web
; --data-dir
data_dir=/var/lib/odoo
;------;
; HTTP ;
;------;
; --http-interface | --xmlrpc-interface
http_interface=0.0.0.0
; --http-port | -p | --xmlrpc-port
http_port=8069
; --longpolling_port
longpolling_port=8072
; --no-http | --no-xmlrpc
http_enable=True
; --proxy-mode
proxy_mode=True
; --x-sendfile
x_sendfile =False
;---------------;
; Testing Group ;
;---------------;
; --test-file
test_file=False
; --test-enable
test_enable=False
; --test-tags
test_tags=False
; --screencasts
screencasts=None
; --screenshots
screenshots=/tmp/odoo_tests
;---------------;
; Logging Group ;
;---------------;
; --logfile
logfile=
; --syslog
syslog=False
; --log-handler | --log-web (--log-handler=odoo.http:DEBUG) | --log-sql (--log-handler=odoo.sql_db:DEBUG)
log_handler=[':INFO']
; --log-db
log_db=False
; --log-db-level
log_db_level=info
; --log-level
log_level=info
;------------;
; SMTP Group ;
;------------;
; --email-from
email_from=
; --from-filter
from_filter=False
; --smtp
smtp_server=
; --smtp-port
smtp_port=25
; --smtp-ssl
smtp_ssl=
; --smtp-user
smtp_user=
; --smtp-password
smtp_password=
; --smtp-ssl-certificate-filename
smtp_ssl_certificate_filename=False
; --smtp-ssl-private-key-filename
smtp_ssl_private_key_filename=False
;----------;
; DB Group ;
;----------;
; --database | -d
db_name=odoo
; --db_user | -r
db_user=odoo
; --db_password | -w
db_password=odoo
; --pg_path
pg_path=
; --db_host
db_host=postgres
; --db_port
db_port=5432
; --db_sslmode
db_sslmode=prefer
; --db_maxconn
db_maxconn=64
; --db-template
db_template=unaccent_template
;------------------------------;
; Internationalisation options ;
;------------------------------;
; --load-language
load_language=en_US
; --language
language=
; --i18n-export
translate_out=
; --i18n-import
translate_in=
; --i18n-overwrite
overwrite_existing_translations=False
; --modules
translate_modules=['all']
;----------;
; Security ;
;----------;
; --no-database-list
list_db=True
;-----;
; WEB ;
;-----;
; --db-filter
dbfilter=.*
;------------------;
; Advanced options ;
;------------------;
; --dev
dev_mode=False
; --shell-interface
shell_interface=ptpython
; --stop-after-init
stop_after_init=False
; --osv-memory-count-limit
osv_memory_count_limit=False
; --transient-age-limit (for deprecated --osv-memory-age-limit)
transient_age_limit=1.0
; --max-cron-threads
max_cron_threads=2
; --unaccent
unaccent=True
; --geoip-db
geoip_database=/usr/share/GeoIP/GeoLite2-City.mmdb
; --workers
workers=0
; --limit-memory-soft
limit_memory_soft=2147483648
; --limit-memory-hard
limit_memory_hard=2684354560
; --limit-time-cpu
limit_time_cpu=120
; --limit-time-real
limit_time_real=240
; --limit-time-real-cron
limit_time_real_cron=600
; --limit-request
limit_request=8192

367
odoo/odoorc.sh Executable file
View File

@@ -0,0 +1,367 @@
#!/bin/bash
set -e
# Define default values for environment variables
set -a
source /.env
set +a
declare -A defaults
defaults=(
[ADMIN_PASSWD]=${ADMIN_PASSWD}
[CSV_INTERNAL_SEP]=${CSV_INTERNAL_SEP}
[PUBLISHER_WARRANTY_URL]=${PUBLISHER_WARRANTY_URL}
[ROOT_PATH]=${ROOT_PATH}
[REPORTGZ]=${REPORTGZ}
[WEBSOCKET_KEEP_ALIVE_TIMEOUT]=${WEBSOCKET_KEEP_ALIVE_TIMEOUT}
[WEBSOCKET_RATE_LIMIT_BURST]=${WEBSOCKET_RATE_LIMIT_BURST}
[WEBSOCKET_RATE_LIMIT_DELAY]=${WEBSOCKET_RATE_LIMIT_DELAY}
[ODOO_RC]=${ODOO_RC}
[SAVE]=${SAVE}
[INIT]=${INIT}
[UPDATE]=${UPDATE}
[DEMO]=${DEMO}
[WITHOUT_DEMO]=${WITHOUT_DEMO}
[IMPORT_PARTIAL]=${IMPORT_PARTIAL}
[PIDFILE]=${PIDFILE}
[ADDONS_PATH]=${ADDONS_PATH}
[UPGRADE_PATH]=${UPGRADE_PATH}
[SERVER_WIDE_MODULES]=${SERVER_WIDE_MODULES}
[DATA_DIR]=${DATA_DIR}
[HTTP_INTERFACE]=${HTTP_INTERFACE}
[HTTP_PORT]=${HTTP_PORT}
[LONGPOLLING_PORT]=${LONGPOLLING_PORT}
[HTTP_ENABLE]=${HTTP_ENABLE}
[PROXY_MODE]=${PROXY_MODE}
[X_SENDFILE]=${X_SENDFILE}
[DBFILTER]=${DBFILTER}
[TEST_FILE]=${TEST_FILE}
[TEST_ENABLE]=${TEST_ENABLE}
[TEST_TAGS]=${TEST_TAGS}
[SCREENCASTS]=${SCREENCASTS}
[SCREENSHOTS]=${SCREENSHOTS}
[LOGFILE]=${LOGFILE}
[SYSLOG]=${SYSLOG}
[LOG_HANDLER]=${LOG_HANDLER}
[LOG_DB]=${LOG_DB}
[LOG_DB_LEVEL]=${LOG_DB_LEVEL}
[LOG_LEVEL]=${LOG_LEVEL}
[EMAIL_FROM]=${EMAIL_FROM}
[FROM_FILTER]=${FROM_FILTER}
[SMTP_SERVER]=${SMTP_SERVER}
[SMTP_PORT]=${SMTP_PORT}
[SMTP_SSL]=${SMTP_SSL}
[SMTP_USER]=${SMTP_USER}
[SMTP_PASSWORD]=${SMTP_PASSWORD}
[SMTP_SSL_CERTIFICATE_FILENAME]=${SMTP_SSL_CERTIFICATE_FILENAME}
[SMTP_SSL_PRIVATE_KEY_FILENAME]=${SMTP_SSL_PRIVATE_KEY_FILENAME}
[DB_NAME]=${DB_NAME}
[DB_USER]=${DB_USER}
[DB_PASSWORD]=${DB_PASSWORD}
[PG_PATH]=${PG_PATH}
[DB_HOST]=${DB_HOST}
[DB_PORT]=${DB_PORT}
[DB_SSLMODE]=${DB_SSLMODE}
[DB_MAXCONN]=${DB_MAXCONN}
[DB_TEMPLATE]=${DB_TEMPLATE}
[LOAD_LANGUAGE]=${LOAD_LANGUAGE}
[LANGUAGE]=${LANGUAGE}
[TRANSLATE_OUT]=${TRANSLATE_OUT}
[TRANSLATE_IN]=${TRANSLATE_IN}
[OVERWRITE_EXISTING_TRANSLATIONS]=${OVERWRITE_EXISTING_TRANSLATIONS}
[TRANSLATE_MODULES]=${TRANSLATE_MODULES}
[LIST_DB]=${LIST_DB}
[DEV_MODE]=${DEV_MODE}
[SHELL_INTERFACE]=${SHELL_INTERFACE}
[STOP_AFTER_INIT]=${STOP_AFTER_INIT}
[OSV_MEMORY_COUNT_LIMIT]=${OSV_MEMORY_COUNT_LIMIT}
[TRANSIENT_AGE_LIMIT]=${TRANSIENT_AGE_LIMIT}
[MAX_CRON_THREADS]=${MAX_CRON_THREADS}
[UNACCENT]=${UNACCENT}
[GEOIP_DATABASE]=${GEOIP_DATABASE}
[WORKERS]=${WORKERS}
[LIMIT_MEMORY_SOFT]=${LIMIT_MEMORY_SOFT}
[LIMIT_MEMORY_HARD]=${LIMIT_MEMORY_HARD}
[LIMIT_TIME_CPU]=${LIMIT_TIME_CPU}
[LIMIT_TIME_REAL]=${LIMIT_TIME_REAL}
[LIMIT_TIME_REAL_CRON]=${LIMIT_TIME_REAL_CRON}
[LIMIT_REQUEST]=${LIMIT_REQUEST}
)
# Define the template
template=$(cat << EOF
[options]
;------------------------------------------;
; Options not exposed on the command line. ;
;------------------------------------------;
admin_passwd={ADMIN_PASSWD}
csv_internal_sep={CSV_INTERNAL_SEP}
publisher_warranty_url={PUBLISHER_WARRANTY_URL}
root_path={ROOT_PATH}
reportgz={REPORTGZ}
websocket_keep_alive_timeout={WEBSOCKET_KEEP_ALIVE_TIMEOUT}
websocket_rate_limit_burst={WEBSOCKET_RATE_LIMIT_BURST}
websocket_rate_limit_delay={WEBSOCKET_RATE_LIMIT_DELAY}
;-----------------------;
; Server startup config ;
;-----------------------;
; --config | -c
config={ODOO_RC}
; --save
save={SAVE}
; --init | -i
init={INIT}
; --update | -u
update={UPDATE}
; --without-demo
demo={DEMO}
without_demo={WITHOUT_DEMO}
; --import-partial
import_partial={IMPORT_PARTIAL}
; --pidfile
pidfile={PIDFILE}
; --addons-path
addons_path={ADDONS_PATH}
; --upgrade-path
upgrade_path={UPGRADE_PATH}
; --load
server_wide_modules={SERVER_WIDE_MODULES}
; --data-dir
data_dir={DATA_DIR}
;------;
; HTTP ;
;------;
; --http-interface | --xmlrpc-interface
http_interface={HTTP_INTERFACE}
; --http-port | -p | --xmlrpc-port
http_port={HTTP_PORT}
; --longpolling_port
longpolling_port={LONGPOLLING_PORT}
; --no-http | --no-xmlrpc
http_enable={HTTP_ENABLE}
; --proxy-mode
proxy_mode={PROXY_MODE}
; --x-sendfile
x_sendfile ={X_SENDFILE}
;---------------;
; Testing Group ;
;---------------;
; --test-file
test_file={TEST_FILE}
; --test-enable
test_enable={TEST_ENABLE}
; --test-tags
test_tags={TEST_FILE}
; --screencasts
screencasts={SCREENCASTS}
; --screenshots
screenshots={SCREENSHOTS}
;---------------;
; Logging Group ;
;---------------;
; --logfile
logfile={LOGFILE}
; --syslog
syslog={SYSLOG}
; --log-handler | --log-web (--log-handler=odoo.http:DEBUG') | --log-sql (--log-handler=odoo.sql_db:DEBUG)
log_handler={LOG_HANDLER}
; --log-db
log_db={LOG_DB}
; --log-db-level
log_db_level={LOG_DB_LEVEL}
; --log-level
log_level={LOG_LEVEL}
;------------;
; SMTP Group ;
;------------;
; --email-from
email_from={EMAIL_FROM}
; --from-filter
from_filter={FROM_FILTER}
; --smtp
smtp_server={SMTP_SERVER}
; --smtp-port
smtp_port={SMTP_PORT}
; --smtp-ssl
smtp_ssl={SMTP_SSL}
; --smtp-user
smtp_user={SMTP_USER}
; --smtp-password
smtp_password={SMTP_PASSWORD}
; --smtp-ssl-certificate-filename
smtp_ssl_certificate_filename={SMTP_SSL_CERTIFICATE_FILENAME}
; --smtp-ssl-private-key-filename
smtp_ssl_private_key_filename={SMTP_SSL_PRIVATE_KEY_FILENAME}
;----------;
; DB Group ;
;----------;
; --database | -d
db_name={DB_NAME}
; --db_user | -r
db_user={DB_USER}
; --db_password | -w
db_password={DB_PASSWORD}
; --pg_path
pg_path={PG_PATH}
; --db_host
db_host={DB_HOST}
; --db_port
db_port={DB_PORT}
; --db_sslmode
db_sslmode={DB_SSLMODE}
; --db_maxconn
db_maxconn={DB_MAXCONN}
; --db-template
db_template={DB_TEMPLATE}
;------------------------------;
; Internationalisation options ;
;------------------------------;
; --load-language
load_language={LOAD_LANGUAGE}
; --language
language={LANGUAGE}
; --i18n-export
translate_out={TRANSLATE_OUT}
; --i18n-import
translate_in={TRANSLATE_IN}
; --i18n-overwrite
overwrite_existing_translations={OVERWRITE_EXISTING_TRANSLATIONS}
; --modules
translate_modules={TRANSLATE_MODULES}
;----------;
; Security ;
;----------;
; --no-database-list
list_db={LIST_DB}
;-----;
; WEB ;
;-----;
; --db-filter
dbfilter={DBFILTER}
;------------------;
; Advanced options ;
;------------------;
; --dev
dev_mode={DEV_MODE}
; --shell-interface
shell_interface={SHELL_INTERFACE}
; --stop-after-init
stop_after_init={STOP_AFTER_INIT}
; --osv-memory-count-limit
osv_memory_count_limit={OSV_MEMORY_COUNT_LIMIT}
; --transient-age-limit (--osv-memory-age-limit deprecated)
transient_age_limit={TRANSIENT_AGE_LIMIT}
; --max-cron-threads
max_cron_threads={MAX_CRON_THREADS}
; --unaccent
unaccent={UNACCENT}
; --geoip-db
geoip_database={GEOIP_DATABASE}
; --workers
workers={WORKERS}
; --limit-memory-soft
limit_memory_soft={LIMIT_MEMORY_SOFT}
; --limit-memory-hard
limit_memory_hard={LIMIT_MEMORY_HARD}
; --limit-time-cpu
limit_time_cpu={LIMIT_TIME_CPU}
; --limit-time-real
limit_time_real={LIMIT_TIME_REAL}
; --limit-time-real-cron
limit_time_real_cron={LIMIT_TIME_REAL_CRON}
; --limit-request
limit_request={LIMIT_REQUEST}
EOF
)
# Override defaults with values from environment variables
for key in "${!defaults[@]}"; do
if [[ ! ${defaults[$key]} =~ ^\{.*\}$ ]]; then
value=${!key:-${defaults[$key]}}
template="${template//\{$key\}/$value}"
fi
done
# Store the result to the odoo.conf file
echo "$template" > ${ODOO_RC}

5
postgres/Dockerfile Normal file
View File

@@ -0,0 +1,5 @@
FROM postgres:15.1
RUN apt-get update && apt-get install postgresql-contrib
COPY ./entrypoint.sh /docker-entrypoint-initdb.d/entrypoint.sh

3
postgres/entrypoint.sh Executable file
View File

@@ -0,0 +1,3 @@
psql -p 5432 -U odoo -d postgres -c "CREATE DATABASE unaccent_template WITH TEMPLATE = template0"
psql -p 5432 -U odoo -d postgres -c "\\c unaccent_template"
psql -p 5432 -U odoo -d postgres -c "CREATE EXTENSION IF NOT EXISTS unaccent;"