Skip to content

Deployment Scripts Reference

Complete reference for the deployment scripts used to manage the Odoo 15 system.

Overview

Two scripts simplify the deployment process:

Script Location Purpose
local_deploy.sh Development machine Commit, merge, and push to GitHub
production_deploy.sh Production server Pull, build, update, and restart services
┌─────────────────────┐         ┌─────────────────────┐
│  Development        │         │  Production         │
│  Machine            │         │  Server             │
│                     │         │                     │
│  local_deploy.sh    │ ──────► │ production_deploy.sh│
│  (git push)         │  GitHub │ (git pull + deploy) │
└─────────────────────┘         └─────────────────────┘

local_deploy.sh

Use this script on your local development machine to commit changes and push to GitHub.

What It Does

  1. Checks for uncommitted changes
  2. Shows what will be committed
  3. Asks for confirmation
  4. Commits to develop branch
  5. Pushes develop to GitHub
  6. Merges develop into main
  7. Pushes main to GitHub
  8. Switches back to develop

Usage

./local_deploy.sh "your commit message"

Examples

# Feature addition
./local_deploy.sh "feat(justcall): Add MMS support"

# Bug fix
./local_deploy.sh "fix(signature): Fix S3 upload timeout"

# Documentation update
./local_deploy.sh "docs: Update API documentation"

# Refactoring
./local_deploy.sh "refactor(pwa): Simplify job list rendering"

Commit Message Format

Use Conventional Commits format:

type(scope): description
Type Description
feat New feature
fix Bug fix
docs Documentation only
style Formatting, no code change
refactor Code restructuring
test Adding tests
chore Maintenance tasks

Workflow Diagram

local_deploy.sh "commit message"
┌───────────────────┐
│ Check for changes │
└───────┬───────────┘
┌───────────────────┐
│ Show changes      │
│ Ask confirmation  │
└───────┬───────────┘
┌───────────────────┐
│ git add -A        │
│ git commit        │
│ (on develop)      │
└───────┬───────────┘
┌───────────────────┐
│ git push develop  │
└───────┬───────────┘
┌───────────────────┐
│ git checkout main │
│ git merge develop │
│ git push main     │
└───────┬───────────┘
┌───────────────────┐
│ git checkout      │
│ develop           │
└───────────────────┘

production_deploy.sh

Use this script on your production server to deploy changes from GitHub.

Quick Reference

./production_deploy.sh {command}

Command Categories

Deployment Commands

Command Description
deploy Full deployment: backup, pull, build all, update all modules
update Quick update: backup, pull, rebuild, update modules
update-module MODULE Update specific Odoo module only

Service Commands

Command Description
start Start all services
stop Stop all services
restart Restart all services
restart-service SERVICE Restart specific service
status Show container status
logs SERVICE View logs (follow mode)
health Run health check

Rebuild Commands

Command Description
rebuild-all Rebuild ALL containers from scratch
rebuild-pwa Rebuild PWA container only
rebuild-docs Rebuild documentation container only

Maintenance Commands

Command Description
backup Create full backup (database + filestore)
init-ssl Initialize Let's Encrypt SSL certificates
db-shell Connect to PostgreSQL
odoo-shell Start Odoo Python shell

Deployment Commands (Detailed)

deploy - Full Deployment

Complete rebuild of everything. Use after major changes.

./production_deploy.sh deploy

What it does:

  1. Checks .env file exists
  2. Creates full backup
  3. Pulls latest code from GitHub
  4. Stops all containers
  5. Rebuilds all Docker images
  6. Starts all services
  7. Waits 60 seconds for startup
  8. Updates ALL Odoo modules
  9. Restarts Odoo
  10. Runs health check
  11. Cleans up old Docker images

When to use:

  • After Dockerfile changes
  • After major infrastructure changes
  • First deployment on new server

update - Quick Update

Most common deployment method. Faster than full deploy.

./production_deploy.sh update

What it does:

  1. Checks .env file exists
  2. Creates backup
  3. Pulls latest code from GitHub
  4. Rebuilds containers if needed
  5. Restarts services
  6. Updates Odoo modules
  7. Restarts Odoo
  8. Runs health check

When to use:

  • After code changes
  • After module updates
  • Regular deployments

update-module - Single Module Update

Update only a specific Odoo module. Fastest option.

./production_deploy.sh update-module MODULE_NAME

Examples:

./production_deploy.sh update-module justcall_sms
./production_deploy.sh update-module jdx_service_signature
./production_deploy.sh update-module jdx_field_service_automation

When to use:

  • After changes to a single module
  • Quick fixes to specific functionality

Service Commands (Detailed)

start / stop / restart

Control all services at once.

./production_deploy.sh start    # Start all
./production_deploy.sh stop     # Stop all
./production_deploy.sh restart  # Restart all

restart-service - Restart Single Service

Restart only one service without affecting others.

./production_deploy.sh restart-service SERVICE

Available services:

Service Description
odoo Odoo ERP application
pwa Field service PWA
docs Documentation portal
nginx Reverse proxy
db PostgreSQL database

Examples:

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

status - Check Container Status

View current state of all containers.

./production_deploy.sh status

Sample output:

NAME      STATUS          PORTS
odoo      Up 2 hours      8069/tcp
pwa       Up 2 hours      5000/tcp
docs      Up 2 hours      8000/tcp
nginx     Up 2 hours      0.0.0.0:80->80/tcp
db        Up 2 hours      5432/tcp

logs - View Logs

View real-time logs from services.

./production_deploy.sh logs SERVICE

Examples:

./production_deploy.sh logs odoo    # Odoo logs
./production_deploy.sh logs pwa     # PWA logs
./production_deploy.sh logs nginx   # Nginx access/error logs
./production_deploy.sh logs         # All logs

Press Ctrl+C to exit log view.


health - Health Check

Run health check on all services.

./production_deploy.sh health

Checks:

  • All containers running
  • Odoo responding on port 8069
  • PWA responding on port 5000
  • Docs responding on port 8000
  • Nginx responding on port 80
  • Database connections

Rebuild Commands (Detailed)

rebuild-all - Full Rebuild

Rebuild ALL Docker containers from scratch (no cache).

./production_deploy.sh rebuild-all

What it does:

  1. Builds all images with --no-cache
  2. Restarts all services
  3. Waits 30 seconds
  4. Runs health check

When to use:

  • After Dockerfile changes
  • After base image updates
  • To fix corrupted containers

rebuild-pwa - Rebuild PWA Only

Rebuild just the PWA container.

./production_deploy.sh rebuild-pwa

When to use:

  • After PWA code changes
  • After PWA dependency updates
  • After static asset changes

rebuild-docs - Rebuild Docs Only

Rebuild just the documentation container.

./production_deploy.sh rebuild-docs

When to use:

  • After documentation changes
  • After mkdocs.yml changes
  • After adding new doc pages

Maintenance Commands (Detailed)

backup - Create Backup

Create full backup before making changes.

./production_deploy.sh backup

Creates:

  • PostgreSQL database dump
  • Odoo filestore backup
  • Timestamped backup files

init-ssl - Initialize SSL

Set up Let's Encrypt SSL certificates.

./production_deploy.sh init-ssl

Prerequisites:

  • Domains configured in .env
  • Port 80 accessible from internet
  • DNS pointing to server

db-shell - Database Shell

Connect directly to PostgreSQL.

./production_deploy.sh db-shell

Opens psql prompt for direct SQL queries.


odoo-shell - Odoo Shell

Start Odoo Python shell for debugging.

./production_deploy.sh odoo-shell

Opens Python REPL with Odoo environment loaded.


Complete Deployment Workflow

Standard Workflow

# === ON YOUR LOCAL MACHINE ===

# 1. Make changes
nano extra-addons/odoo/justcall_sms/models/justcall_sms.py

# 2. Test locally
docker compose restart odoo

# 3. Deploy to GitHub
./local_deploy.sh "feat(justcall): Add retry logic"


# === ON PRODUCTION SERVER ===

# 4. SSH to server
ssh user@production-server
cd /opt/odoo15-production

# 5. Deploy
./production_deploy.sh update

# 6. Verify
./production_deploy.sh status
./production_deploy.sh logs odoo

Quick Module Fix

# Local
./local_deploy.sh "fix(signature): Fix upload bug"

# Production
./production_deploy.sh update-module jdx_service_signature

Documentation Update

# Local
./local_deploy.sh "docs: Update API reference"

# Production
./production_deploy.sh rebuild-docs

Full Infrastructure Update

# Local
./local_deploy.sh "chore: Update Dockerfile dependencies"

# Production
./production_deploy.sh deploy

Environment Variables

Both scripts use these environment variables from .env:

Variable Default Description
DATABASE odoo_production Database name for module updates
DOMAIN_ERP - ERP domain for SSL
DOMAIN_PWA - PWA domain for SSL
DOMAIN_DOCS - Docs domain for SSL
LETSENCRYPT_EMAIL - Email for SSL certificates

Troubleshooting

Script Permission Denied

chmod +x local_deploy.sh
chmod +x production_deploy.sh

Git Push Fails

# Check remote
git remote -v

# Set upstream
git push --set-upstream origin develop

Docker Compose Not Found

The script auto-detects docker compose vs docker-compose:

# Modern Docker
docker compose version

# Legacy
docker-compose version

Module Update Fails

# Check Odoo logs
./production_deploy.sh logs odoo

# Try full update
./production_deploy.sh update

Container Won't Start

# Check status
./production_deploy.sh status

# View logs
./production_deploy.sh logs

# Full rebuild
./production_deploy.sh rebuild-all