Install Odoo using Docker, Nginx on Ubuntu 20.04 — AWS

Prerequisites

  1. A running EC2 Instance. Learn how to create an AWS EC2 instance. Please use Ubuntu 20.04
  2. Assigned a Elastic IP to your EC2 Instance.
  3. Setup Amazon RDS and connect it with EC2 Instance (Please choose PostgreSQL 12 for Engine).
  4. Setup and configure Route 53 and point your domain to AWS.
  5. Successful SSH connection to your EC2 Instance.
  6. Install Docker on Ubuntu 20.04
  7. Install Docker Compose on Ubuntu 20.04.
  • Ubuntu 20.04 on EC2
  • PostgreSQL 12 on Amazon RDS
  • Domain pointed to the EC2 Elastic IP address
  • Docker installed and configured
  • Docker Compose installed and configured

Step 1: Create a project directory

sudo mkdir odoo-project

Step 2: Create Docker Compose YAML file

cd odoo-projectsudo nano docker-compose.yml
version: '3'
services:
odoo:
container_name: odoo
image: odoo:latest
volumes:
- ./addons-extra:/mnt/extra-addons
- ./etc/odoo/config:/etc/odoo
- odoo-web-data:/var/lib/odoo
ports:
- "8069:8069"
nginx:
container_name: nginx
image: nginx:latest
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- ./nginx/conf:/etc/nginx/conf.d
- ./certbot/conf:/etc/nginx/ssl
- ./certbot/data:/var/www/html
certbot:
container_name: certbot
image: certbot/certbot:latest
command: certonly --webroot --webroot-path=/var/www/html -- email youremail@mail.com --agree-tos --no-eff-email -d domain.com -d www.domain.com
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/logs:/var/log/letsencrypt
- ./certbot/data:/var/www/html
volumes:
odoo-web-data:
  • version: Compose file version which is compatible with the Docker Engine. You can check compatibility here.
  • services: here we have 3 services named odoo, nginx and certbot.
  • image: We use latest Odoo, Nginx and Certbot images available in Docker hub.
  • volumes:
  • nginx/conf: here we will place the Nginx configuration file to be synced with the default Nginx conf.d folder inside the container.
  • cedtbot/conf: this is where we will receive the SSL certificate and this will be synced with the folder we wish to inside the container.
  • ports: configure the container to listen upon the listed ports.
  • command: the command used to receive the SSL certificate.

Step 3: Create Odoo Configuration

sudo mkdir -p etc/odoo/config
sudo nano /etc/odoo/odoo.conf
[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = RDS_ENDPOINT
db_user = RDS_user
db_password = RDS_user_password

Step 4: Configure aNginx

sudo mkdir -p nginx/config
sudo nano /nginx/conf/default.conf
server {
listen [::]:80;
listen 80;
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;
}
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;
}
}

Step 5: Deploy Oddo with Docker

docker-compose up -d
docker-compose ps

Step 6: Configure SSL for Odoo in Docker

sudo nano nginx/conf/default.confserver {
listen [::]:80;
listen 80;
server_name domain.com; return 301 https://www.domain.com$request_uri;
}
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
server_name domain.com; ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;
return 301 https://www.domain.com$request_uri;
}
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
server_name domain.com; ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;
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;
}
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;
}
}
docker-compose restart nginx

Step 7: Setup Odoo

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
CloudBooklet

CloudBooklet

Installation and Set Up of Web Applications on Google Cloud