Quickstart
In a nutshell, here's what you need to do to deploy Odoo on your server:
- Clone/copy the Odoo On-Premise Setup Package repository to your server
- Make a local copy of the .env.template file and insert your setup parameters
- Make the startup script executable and execute it
- Change the password of the admin user in your Odoo production environment
Detailed configuration steps are described below.
Server preparation
Here are a few steps that may be necessary when setting up a server. Some of these you may have already done.
- You need a server where you have root access and it is running Linux. Tested and supported versions are Ubuntu 18.04, 20.04, or 22.04.
- You have to set up a DNS A record to map your server's IP address to your domain (usually done on the site where you bought the domain name).
- Generate an SSH key for your server, for example, using ssh-keygen -t rsa
- Copy the generated key and add it to your GitHub. To access the key, use cat ~/.ssh/id_rsa.pub
For more info, see: Adding a new SSH key to your GitHub account
Setting up Odoo
1. Clone or copy the Odoo On-Premise Setup Package repository to your server and navigate to it
git clone git@github.com:winotto-ou/odoo_setup.git YOUR_PROJECT_NAME
CD YOUR_PROJECT_NAME
2. Make a copy of the .env.template file and name it .env
cp .env.template .env
3. Edit parameters in .env file (see section .env file parameters below)
nano .env
4. Add execute rights to the starting script
sudo chmod +x starting_script.sh
5. Run the starting script
bash starting_script.sh
6. Change production environment admin user password
To change the default password:
- Navigate to your production environment and log in.
- Once logged in, navigate to the user settings. Usually, this can be found by clicking on your username or avatar in the top right corner of the screen.
- Select My Profile from the dropdown.
- Navigate to the Account Security tab on the user profile form and press the Change Password button.
.env file parameters
Here is a short explanation of the .env file of the Odoo On-Premise Setup Package.
# Localhost Testing
LOCALHOST_TESTING: Use this to test this setup in localhost.
This will bypass real cert generation and add your testing URLs to your OS host file.
Also, cron jobs are not created. DO NOT use real URLs.
For example, add localhost at the beginning (localhost.my.url.com).
Navigating the site will give a security warning in most browsers.
# Main Variables
POSTGRES_VERSION: Specifies the PostgreSQL version. It should be 12.0 or above.
* EMAIL: Email address is required for certificate generation.
HTTP_BODY_SIZE: Maximum allowed size of the client request body, used by nginx.
# Production Environment Variables
* PRODUCTION_URL: URL for the production instance of Odoo.
* ADMIN_PASSWD: Master password, needed for accessing database management screens.
* DB_PASSWORD: Password for the Odoo database.
DB_NAME: Name of the Odoo database.
This database will be automatically created during setup.
Choose carefully. It can't be changed later.
WORKERS: Number of worker processes for Odoo.
Rule of thumb for maximum workers: (#CPU * 2) + 1 - cron_workers. So for server with 4CPU and one cron worker (4*2) + 1 - 1 = 8.
Rule of thumb for needed workers: 1 worker ~= 6 concurrent odoo users
LIMIT_MEMORY_SOFT: Maximum allowed virtual memory per worker (in bytes).
When reached, the worker will be reset after the current request.
Default is 2048 MiB (2048 * 1024 * 1024).
LIMIT_MEMORY_HARD: Maximum allowed virtual memory per worker (in bytes).
When reached, any memory allocation will fail (default 2560 MiB = 2560 * 1024 * 1024).
LIMIT_TIME_CPU: Maximum allowed CPU time per request in seconds (default 60).
LIMIT_TIME_REAL: Maximum allowed real-time per request in seconds (default 120).
# Test Environment Variables
All the same variables as in production, except DB_NAME is replaced with two other variables
allowing database management and multiple databases.
Required changes to parameters are the same as in the production section.
...
TEST_DBFILTER: Database filter pattern.
TEST_LIST_DB: Flag to enable listing databases in the test environment
when navigating to https://YourOdooUrl/web/database/manager.
...
# Backups
BACKUP_DIR: Directory where backups will be stored.
BACKUP_KEEP_DAYS: Number of days to keep backups.
BACKUP_CRON_SCHEDULE: Cron schedule for automated backups.
Folder structure
Odoo On-Premise Setup Package consists of the following files and folders:
addons
production - Folder for custom modules for production.
my_custom_modules - This could be, for example, a Git repository
my_module - Folder containing Odoo module files
apt.txt - All apt packages listed here will be automatically installed
requirements.txt - All Python packages listed here
will be automatically installed
test - Folder for custom modules for testing (same structure as above)
certbot - Folder holding all information for certificates and renewals
cron-scripts
backup_script.sh - Script that handles production environment auto backups.
This is run by cron
renew_script.sh - Script that handles renewing certificates.
This is run by cron
log
letsencrypt - folder containing all Let's Encrypt log files
backup_script.log - Log file for backup job
renew_script.log - Log file for script renewing job
nginx-templates
production.conf.template - Template for generating production environment
Nginx configuration
test.conf.template - Template for generating test environment nginx conf
odoo-conf
odoo-entrypoint.sh - Default entrypoint is overwritten to support Python and
APT package installation when starting Odoo container. It also supports dynamic
configuration file generation for Odoo
su.text - Gives Odoo user the right to use sudo without prompting for a password
inside the Odoo container. This is needed for automatic apt package installation
template.conf - Template used for generating Odoo configuration files
.env.template - Default file for variables. This is the file that needs to be copied
and named .env. This is the only file that needs user input
docker-compose.yml - File that holds all information about Docker containers
and orchestrates them. Just use Docker commands for running, stopping,
and restarting containers
starting_script.sh - File that handles initial setup. Not needed after that