Skip to content

Deployment Guide

Complete deployment guide using production_deploy.sh - the centralized deployment script.

Deployment Script Overview

All deployment operations use ./production_deploy.sh, which reads configuration from .env.

# View current configuration
./production_deploy.sh config

# View all available commands
./production_deploy.sh help

Quick Reference

Command Description
deploy Full deployment (backup, pull, build, update modules)
update Quick update (backup, pull, rebuild, update modules)
start Start all services
stop Stop all services
restart Restart all services
status Check service status
logs View logs
init-ssl Full SSL setup
config Show current configuration

Environments

Environment Config Database Exposed Ports
Test docker-compose.test.yml Local PostgreSQL All
Production docker-compose.prod.yml AWS RDS Only 80, 443

Test Environment Deployment

Prerequisites

  • Docker and Docker Compose installed
  • Git access to repository
  • Ports available: 80, 443, 8016, 8000, 8001, 8002

Steps

# 1. Clone repository
git clone git@github.com:yourorg/odoo15-production.git
cd odoo15-production

# 2. Configure environment
cp .env.example .env
nano .env  # Verify settings

# 3. Verify configuration
./production_deploy.sh config

# 4. Start services
./production_deploy.sh start

# 5. Verify services
./production_deploy.sh health

Access URLs (Test)

Service URL
Odoo http://localhost:8016
Landing Page http://localhost
PWA http://localhost:8000
Docs http://localhost:8002

Production Environment Deployment

Prerequisites

  • AWS EC2/Lightsail instance
  • AWS RDS PostgreSQL instance
  • Domain names configured (DNS pointing to server)
  • Ports 80, 443 open in security group

Step 1: Initial Setup

# SSH to production server
ssh user@production-server

# Clone repository
git clone git@github.com:yourorg/odoo15-production.git
cd odoo15-production

# Create production .env
cp .env.example .env
nano .env

Step 2: Configure .env for Production

# Environment
ENVIRONMENT=production
GIT_BRANCH=main

# Docker Compose (use production overlay)
COMPOSE_FILE=docker-compose.yml:docker-compose.prod.yml

# Database (AWS RDS)
DB_HOST=your-db.xxxxx.us-east-1.rds.amazonaws.com
DB_PORT=5432
DB_NAME=odoo_production
DB_USER=odoo_admin
DB_PASSWORD=<strong-password>

# Domains
DOMAIN_LANDING=yourcompany.com
DOMAIN_ERP=erp.yourcompany.com
DOMAIN_PWA=pwa.yourcompany.com
DOMAIN_DOCS=docs.yourcompany.com

# SSL
LETSENCRYPT_EMAIL=admin@yourcompany.com

Step 3: SSL Certificate Setup

# Full SSL setup (recommended)
./production_deploy.sh init-ssl

This runs the following automatically:

  1. Creates dummy self-signed certificates
  2. Generates nginx config with your domains
  3. Starts nginx with HTTPS
  4. Requests real certificates from Let's Encrypt

Manual SSL Steps (if needed)

# Step-by-step SSL setup
./production_deploy.sh init-ssl-dummy      # 1. Create dummy certs
./production_deploy.sh configure-nginx     # 2. Generate nginx config
./production_deploy.sh restart             # 3. Start services
./production_deploy.sh init-ssl-request    # 4. Get real certs

Step 4: Deploy Application

# Start all services
./production_deploy.sh start

# Or full deployment (includes module updates)
./production_deploy.sh deploy

Step 5: Setup SSL Auto-Renewal

# Add to root crontab
sudo crontab -e

# Add this line (runs every Sunday at 3 AM):
0 3 * * 0 /path/to/odoo15-production/scripts/ssl-renew-cron.sh >> /var/log/ssl-renew.log 2>&1

Deployment Commands

Full Deployment

Use for major updates or initial deployment:

./production_deploy.sh deploy

This performs:

  1. Check .env exists
  2. Create backup
  3. Pull latest code from GIT_BRANCH
  4. Stop containers
  5. Build Docker images
  6. Start services
  7. Update all Odoo modules
  8. Run health checks

Quick Update

Use for routine updates:

./production_deploy.sh update

This performs:

  1. Check .env exists
  2. Create backup
  3. Pull latest code
  4. Rebuild containers (if needed)
  5. Restart services
  6. Update Odoo modules
  7. Run health checks

Update Single Module

./production_deploy.sh update-module justcall_sms

Service Management

Start/Stop/Restart

# All services
./production_deploy.sh start
./production_deploy.sh stop
./production_deploy.sh restart

# Single service
./production_deploy.sh restart-service odoo
./production_deploy.sh restart-service nginx
./production_deploy.sh restart-service pwa

View Status

./production_deploy.sh status

View Logs

# All services
./production_deploy.sh logs

# Specific service
./production_deploy.sh logs odoo
./production_deploy.sh logs nginx

Rebuild Services

# Rebuild all
./production_deploy.sh rebuild-all

# Rebuild specific service
./production_deploy.sh rebuild-pwa
./production_deploy.sh rebuild-docs
./production_deploy.sh rebuild-landing

SSL Commands

Command Description
init-ssl Full SSL setup (dummy → configure → request)
init-ssl-dummy Create self-signed dummy certificates
init-ssl-request Request real certificates from Let's Encrypt
renew-ssl Renew existing certificates
configure-nginx Generate nginx config with domains from .env

SSL Certificate Locations

nginx/ssl/
└── live/
    └── yourcompany.com/
        ├── fullchain.pem    # Certificate chain
        └── privkey.pem      # Private key

Manual Certificate Renewal

./production_deploy.sh renew-ssl

Database Management

Access Database Shell

./production_deploy.sh db-shell

Odoo Shell

./production_deploy.sh odoo-shell

Install/Update Module

# Via deploy script
./production_deploy.sh update-module module_name

# Or directly
docker compose exec odoo odoo -u module_name --stop-after-init -d $DB_NAME

Backup & Recovery

Create Backup

./production_deploy.sh backup

This runs ./scripts/backup.sh full which backs up:

  • Database (pg_dump)
  • Filestore (./odoo-data)
  • Configuration files

Restore from Backup

./scripts/restore.sh <backup-file>

Deployment Checklist

Pre-Deployment

  • Code reviewed and tested
  • .env configured correctly
  • Database backup taken (./production_deploy.sh backup)
  • Team notified

Deployment

  • Run deployment command
  • Verify health checks pass
  • Check logs for errors

Post-Deployment

  • Test critical functionality
  • Monitor logs for 15 minutes
  • Verify backups running
  • Update documentation if needed

Rollback Procedure

If deployment fails:

# 1. Stop services
./production_deploy.sh stop

# 2. Restore previous code
git checkout <previous-tag>

# 3. Restore database if needed
./scripts/restore.sh <backup-file>

# 4. Start services
./production_deploy.sh start

# 5. Verify rollback
./production_deploy.sh health

Troubleshooting

View Configuration

./production_deploy.sh config

Service Won't Start

# Check logs
./production_deploy.sh logs <service>

# Check container status
./production_deploy.sh status

# Force recreate
docker compose up -d --force-recreate <service>

Database Connection Issues

# Test database connection
docker compose exec db pg_isready -U odoo

# Check database exists
docker compose exec db psql -U odoo -l

SSL Certificate Issues

# Test nginx config
docker compose exec nginx nginx -t

# Check certificate files exist
ls -la nginx/ssl/live/*/

# Request new certificates
./production_deploy.sh init-ssl-request

Nginx Issues

# Test config
docker compose exec nginx nginx -t

# Reload config
docker compose exec nginx nginx -s reload

# View nginx logs
./production_deploy.sh logs nginx

File Reference

File Purpose
production_deploy.sh Main deployment script
scripts/ssl-init.sh SSL certificate management
scripts/ssl-renew-cron.sh SSL auto-renewal (cron)
scripts/backup.sh Backup script
scripts/restore.sh Restore script
scripts/health-check.sh Health check script
nginx/conf.d/default.conf Active nginx config
nginx/conf.d/production.conf.template Production HTTPS template