-
Notifications
You must be signed in to change notification settings - Fork 0
Home
First, you have to install docker-compose, this will install docker.
sudo apt install docker-composemkdir dockerdoo
cd dockerdooWe use this version, as is configured to our needs and creates an odoo image from scratch (you'll see the diference later)
git clone -b $Version https://github.com/solvosci/dockerdoo $instance-prodReplace $Version with the Odoo version (e.g., 17.0). $instance usually is the company name, followed by -prod or -test, depending on the environment.
Before running the compose you should evaluate the .env file, which sets most variables used in this project.
nano .envUpdate the following variables:
WORKERS=4
ADMIN_PASSWORD=$new_password
DBFILTER=^$instance.*$Keep in mind, that next variable, only should be updated when Nginx is fully configurated as we do it here.
PROXY_MODE=True| Environment | HTTP | Gevent | PostgreSQL |
|---|---|---|---|
| Production | 8169 | 8172 | 54321 |
| Test | 8269 | 8272 | 54322 |
sudo docker-compose up -dIf you encounter dependency issues related with wheel, edit the Dockerfile and add the following at line 116 and run previous command again:
RUN pip install --upgrade pip setuptools wheelVisit your server's $IP_or_VMName on port 8169 in a browser. If the database creation screen shows up, it worked.
- Master password: as in
.env - Database name:
$instance - Email:
admin - Password:
$new_password
We'll use Webmin as it makes our work easier by having visual files and the capability to edit Nginx archives on the fly.
sudo -iwget -qO- http://www.webmin.com/jcameron-key.asc | gpg --dearmor -o /usr/share/keyrings/webmin.gpg
nano /etc/apt/sources.list.d/webmin.listAdd:
deb [signed-by=/usr/share/keyrings/webmin.gpg] http://download.webmin.com/download/repository sarge contribapt update
apt install webminFrom browser:
To acces Webmin the user/password are the same of the machine's user.
https://localhost:10000To use Webmin from another machine previously, you have to configure like this (SSH tunnel):
ssh -L 10000:$ip_or_vm:10000 -N $userNow it's the moment to clone repositories, we usually use web_responsive that it's an addon from OCA, so your first repo should be /OCA/web. Remember that you have to be root to acces /var/lib/docker/
cd /var/lib/docker/volumes/${instance}_odoo_modules/_data
git clone -b $version https://github.com/$OWNER/$REPO
exitCheck if all repos and addons you need are visible on Odoo by restarting it and Update Addon List
sudo docker-compose down
sudo docker-compose up -dHere we'll do a basic Nginx configuration, to use Port 80
sudo -i
apt install nginxFirst, remove de default archive (with Webmin or by command), and create one called odoo-80
rm /etc/nginx/sites-available/default
nano /etc/nginx/sites-available/odooPaste the following (you must change server name with the ip or VM name):
# odoo server
upstream odoo {
server 127.0.0.1:8169;
}
upstream odoochat {
server 127.0.0.1:8172;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name $ip_or_vm;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
client_max_body_size 128M;
large_client_header_buffers 16 32k;
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
location /websocket {
proxy_pass http://odoochat;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
}
location / {
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_pass http://odoo;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
}
gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
Again, remove the default archive and create a symbolic link with the one created before
rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/odoo-80 /etc/nginx/sites-enabled/odoo-80Now, it's moment to end .env configuration we talked before.
nano .env
PROXY_MODE=Truesudo docker-compose down
sudo docker-compose up -d
systemctl restart nginx.serviceIf Nginx fails, check:
systemctl status nginx.serviceNote: If you follow Odoo's configuration system and cookie_flags fails, check first if Nginx version is 1.18 and remove next lines (requires Nginx 1.19+).
proxy_cookie_flags session_id samesite=lax secure; # requires nginx 1.19.8After all configuration, it's time to check if it works on port 80 by putting the server name on your search browser and see if Odoo is active, if it doesn´t, check ufw and allow 80/tcp
sudo ufw status
sudo ufw allow 80/tcp- Configure languages in Odoo
- Install required modules
- Customize environment as needed
services:
odoo:
# image: iterativodo/dockerdoo:${ODOO_VERSION}
build:
context: .
dockerfile: Dockerfile
env_file: .env- Full control of image
- Add dependencies
- Recommended for consistent environments
services:
odoo:
image: iterativodo/dockerdoo:${ODOO_VERSION}
# build:
# context: .
# dockerfile: Dockerfile
env_file: .envUse when:
- Having internet restricted/limited
- Quick demo needed
Use Dockerfile unless in restricted environments or demos. Toggle in docker-compose.yml by commenting/uncommenting the relevant lines.
- External Nginx setup (here are the basis)
- Let's Encrypt integration
- Future log management improvements