This document describes how to build and run the TestizerFunnelEngine service in Docker.
Suitable for both local deployment and server deployment.
Before starting, you need:
- Docker installed;
.envfile in the project root with correct settings:- MySQL (MODX) database access;
- Brevo settings (API key, base URL, lists);
- Application parameters (
APP_ENV,APP_DRY_RUN, etc.).
The container uses the same environment variables as local Python execution.
From the project root:
docker build -t testizer-funnel-engine .After running this command, you will have an image named testizer-funnel-engine containing all project code and dependencies from requirements.txt.
The main task corresponds to the local command:
python -m app.mainIn Docker, it will look like this:
docker run --rm --env-file .env testizer-funnel-engineImportant points:
--env-file .envpasses environment variables from the local.envfile into the container;- the container will connect to MySQL using
DB_HOST,DB_PORT,DB_USER,DB_PASSWORD,DB_NAME,DB_CHARSETparameters.
If the database and Docker container are on the same machine, you may need to change DB_HOST. For example:
- use
host.docker.internalinstead of127.0.0.1(depends on environment and hosting).
The service can work in two modes:
-
APP_DRY_RUN=trueDoes not actually send anything to Brevo, only makes requests, writes logs, and can be used to verify logic.
-
APP_DRY_RUN=falseFull production mode: contacts are sent to Brevo, funnel entries and purchases are recorded for real.
Examples:
Running in dry run:
docker run --rm --env-file .env -e APP_DRY_RUN=true testizer-funnel-engineRunning in production mode:
docker run --rm --env-file .env -e APP_DRY_RUN=false testizer-funnel-engineIf the APP_DRY_RUN variable is already specified in .env, you don't need to pass it via -e, and can manage the mode directly in .env.
There are two basic options.
On the server, you can:
- configure cron (or a scheduler in the hosting panel) that runs a command like this every N minutes:
docker run --rm --env-file /path/to/.env testizer-funnel-engineEach such run performs one full cycle:
- fetches candidates from MODX;
- sends contacts to Brevo;
- records funnel entry;
- syncs purchases and updates status.
Repeated runs are safe: the logic relies on the state of the funnel_entries table and does not duplicate data.
If the service will run in Kubernetes, Docker Swarm, or another orchestration system:
- use the same
testizer-funnel-engineimage; - container startup command:
python -m app.main; - environment variables and schedule are set by the orchestrator.
For additional verification, you can run tests directly in the container:
docker run --rm testizer-funnel-engine python -m pytestThis is not required for production, but useful:
- for debugging;
- for manual verification before deployment;
- if the server doesn't have local Python but has Docker.
-
Build the image:
docker build -t testizer-funnel-engine .
-
Test in dry run mode:
docker run --rm --env-file .env -e APP_DRY_RUN=true testizer-funnel-engine
-
After verification, switch to production mode:
docker run --rm --env-file .env -e APP_DRY_RUN=false testizer-funnel-engine
-
Connect the Docker command to the server schedule and run with the required frequency.