App Docker Compose Deployment
Relevant source files
The following files were used as context for generating this wiki page:
The App Docker Compose Deployment facilitates the containerization and orchestration of the OdooConnectorAPI and its required dependencies. The project utilizes Docker to package a RESTful FastAPI application that serves as a bridge between external clients and the Odoo ERP system. By using Docker Compose, the system ensures a consistent environment for both development and local testing.
Sources: README.md:3-7, docker-compose.yml:1-13
Architecture Overview
The deployment architecture is split into two primary segments: the API application layer and the Odoo ERP backend layer. The API layer runs a FastAPI server, while the backend layer consists of an Odoo instance supported by a PostgreSQL database.
API Service Components
The main application service (defined as web in the root configuration) is built directly from the local repository. It executes the FastAPI application using the Uvicorn ASGI server and maps internal port 8000 to the host.
Sources: docker-compose.yml:4-13, app/main.py:7-9
Odoo Backend Infrastructure
A separate configuration under the odoo/ directory defines the backend stack, comprising an Odoo v17 service and a PostgreSQL v13 database. These services communicate over a private network named mynetwork and include health checks to ensure service readiness.
Sources: odoo/docker-compose.yml:3-56
The diagram shows the communication flow from the external user through the FastAPI connector to the containerized Odoo and Database instances.
Sources: docker-compose.yml:10-13, odoo/docker-compose.yml:7-8, app/main.py:12-15
Configuration and Environment Variables
The application relies on environment variables to establish a connection with the Odoo instance. These variables are typically loaded from a .env file and passed into the containers via the Docker Compose configuration.
| Variable Name | Description | Default / Source File |
|---|---|---|
ODOO_URL | The hostname or IP address of the Odoo server | ${ODOO_URL} or localhost |
ODOO_DB | The name of the Odoo database to connect to | ${ODOO_DB} or mydb |
ODOO_USERNAME | The username for Odoo authentication | ${ODOO_USERNAME} or admin |
ODOO_PASSWORD | The password for Odoo authentication | ${ODOO_PASSWORD} or admin |
Sources: docker-compose.yml:10-13, app/main.py:12-15, README.md:46-48
Service Definitions
API Web Service
The web service builds the application using a Dockerfile in the root directory and runs with auto-reload enabled for development.
web:
build: .
command: uvicorn app.main:app --host 0.0.0.0 --reload
ports:
- "8000:8000"
environment:
ODOO_URL: ${ODOO_URL}
ODOO_DB: ${ODOO_DB}
ODOO_USERNAME: ${ODOO_USERNAME}
ODOO_PASSWORD: ${ODOO_PASSWORD}
Sources: docker-compose.yml:3-13
Odoo Backend Services
The backend deployment includes resource limits and security optimizations (e.g., no-new-privileges, cap_drop).
- Odoo Service: Runs Odoo v17, depends on the database, and exposes port 8069.
- Database Service: Runs PostgreSQL 13, initializing a database named
odoodb.
The sequence illustrates the authentication and data retrieval process between the API and the Odoo backend.
Sources: odoo/docker-compose.yml:25-36, app/main.py:27-38, odoo/test_odoo_connection.py:9-12
Deployment Workflow
To deploy the application using Docker Compose, the following steps are executed:
- Image Building: The
docker-compose up --buildcommand triggers the creation of the application image based on therequirements.txtdependencies. - Network Setup: Docker creates the specified networks (e.g.,
mynetwork) to allow inter-container communication. - Dependency Management: The Odoo container waits for the Database container to be healthy via
pg_isreadychecks. - Application Launch: FastAPI starts via Uvicorn, making the endpoints
/and/get/partnersavailable.
Sources: README.md:52-58, odoo/docker-compose.yml:38-42, app/main.py:20-25
Summary
The Docker Compose deployment provides a robust, containerized environment for OdooConnectorAPI. By encapsulating the FastAPI application and its Odoo/Postgres backend, it ensures that developers can replicate production-like environments locally with minimal configuration, relying on environment variables for flexible connectivity.
Sources: README.md:5-7, docker-compose.yml:1-13