Deployment with Docker Compose
This guide walks you through deploying the WhatsApp Agent using Docker Compose. This is the recommended method for running the application in a production-like environment.
Prerequisites
Ensure you have completed all the steps in the Initial Setup & Configuration guide, especially creating the deploy/deploy.env file.
Building the Docker Image (Optional)
The compose.yml file is configured to pull a pre-built image from a container registry. However, if you have made local changes to the code, you will need to build the image yourself.
From the root of the project, run the following command:
# Replace 'your-registry/whatsapp-agent:latest' with your image name and tag
docker build --pull -f deploy/Containerfile -t your-registry/whatsapp-agent:latest .
After building, you must update the image: key in deploy/compose.yml for the webhook and worker services to point to your newly built image.
Running the Application
-
Navigate to the deploy directory:
cd deploy -
Start the services: Run the following command to start all services (application, worker, database, and Redis) in detached mode:
docker compose up -d
Verifying the Deployment
To check the status of your running containers, use the ps command:
docker compose ps
You should see all services (webhook, worker, postgres, redis) with a STATUS of running or healthy.
Viewing Logs
To monitor the application's output and troubleshoot issues, you can view the logs for each service.
-
Webhook Service Logs (handles incoming API requests):
docker compose logs -f webhook -
Worker Service Logs (handles background jobs like CRM notifications):
docker compose logs -f worker
Press Ctrl+C to stop tailing the logs.
Automatic Database Migrations
The application's entrypoint script (deploy/entrypoint.sh) is configured to automatically run database migrations using Alembic every time the webhook service starts. This ensures your database schema is always up-to-date with the application's requirements.
You should see log output from Alembic during the initial startup of the webhook container.