Crear la carpeta odoo y dentro crear el ficher docker-compose.yml
version: '3.8'
services:
db:
image: postgres
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata
ports:
# <Puerto expuesto> : < Puerto dentro del container>
# Solo para desarrollo. Comentar en produccion
- '5432:5432'
expose:
# Abre el puerto 5432 en el container al exterior sin tocar nada de la configuración del postgresql
# Solo para desarrollo. Comentar en produccion
- '5432'
restart: always # run as a service
odoo16:
image: odoo:16.0
container_name: odoo16
depends_on:
- db
ports:
- "8069:8069"
tty: true
command: -- --dev=reload
# command: odoo scaffold /mnt/extra-addons/test_module
volumes:
- odoo-web-data:/var/lib/odoo
- ./addons:/mnt/extra-addons
- ./etc:/etc/odoo
restart: always # run as a service
pgadmin:
image: dpage/pgadmin4:4.6
container_name: pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin
PGADMIN_DEFAULT_PASSWORD: miclave
PGADMIN_LISTEN_PORT: 80
ports:
- "8080:80"
links:
- "db:pgsql-server"
nginx:
image: nginx:latest
container_name: nginx
depends_on:
- odoo16
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- 80:80
- 443:443
volumes:
odoo-web-data:
odoo-db-data:
Crear el fichero nginx.conf dentro de la carpeta odoo y añadir el siguiente código:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
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;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
server_name "~^www.(.*)$" ;
return 301 $scheme://$1$request_uri ;
}
server {
listen 80 default;
# increase proxy buffer to handle some Odoo web requests
proxy_buffers 16 64k;
proxy_buffer_size 128k;
# Specifies the maximum accepted body size of a client request,
# as indicated by the request header Content-Length.
client_max_body_size 200m;
location / {
proxy_pass http://odoo16:8069;
# force timeouts if the backend dies
proxy_read_timeout 600s;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
# set headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# cache some static data in memory for 60mins.
# under heavy load this should relieve stress on the OpenERP web interface a bit.
location ~* /web/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo16:8069;
}
}
}