Docker Deployment
Relevant source files
The following files were used as context for generating this wiki page:Traduora is designed for easy deployment using Docker and Docker Compose, enabling a quick setup in about 5 minutes. This approach encapsulates the application, its database, and dependencies into a set of coordinated containers. Pre-built images are available from Docker Hub, simplifying the process of running Traduora in various environments.
The deployment is structured around a base docker-compose.yaml file, which can be extended with database-specific configurations for either PostgreSQL or MySQL. This modular setup provides flexibility while maintaining a consistent core architecture. For more advanced setups, a Kubernetes deployment configuration is also provided, demonstrating the application's cloud-native capabilities. For more details on configuration options, see the Configuration documentation.
Architecture Overview
The Docker deployment consists of three main services orchestrated by Docker Compose: traduora (the main application), db (the database), and wait (a utility to manage startup order). The traduora service depends on the db service being available. The wait service ensures that the database is ready to accept connections before the main application starts.
This diagram illustrates the service relationships and dependencies within the Docker Compose setup.
Core Services
The base deployment is defined in docker-compose.yaml. It outlines the services, networks, and volumes required to run the application.
Sources: docker-compose.yaml
Service Definitions
| Service | Image | Ports | Depends On | Description |
|---|---|---|---|---|
traduora | traduora/traduora:latest | 8080:8080 | db, wait | The main application container. It exposes port 8080 for HTTP traffic. |
db | postgres:13-alpine | 5432:5432 | - | The default database service (PostgreSQL). Its data is persisted in a named volume traduora-db. |
wait | ufoscout/docker-compose-wait:latest | - | db | A utility container that waits for the database to be ready before exiting, ensuring traduora starts correctly. |
Sources: docker-compose.yaml:10-48, CREDITS.md:10-11
Startup Sequence
The wait service plays a crucial role in orchestrating a clean startup. It uses the docker-compose-wait utility to poll the database port until it's available. The traduora service has a depends_on condition for both db and wait, ensuring it only starts after the database is confirmed to be running.
This sequence diagram shows the startup process when docker-compose up is executed.
Database Configuration
Traduora supports both PostgreSQL and MySQL as database backends. The base docker-compose.yaml defaults to PostgreSQL. To use a different database, you can use an override file.
PostgreSQL (Default)
The default configuration uses the postgres:13-alpine image. Key environment variables are set to configure the database user, password, and name.
# docker-compose.yaml:18-30
db:
image: postgres:13-alpine
restart: always
environment:
- POSTGRES_USER=${TR_DB_USER:-traduora}
- POSTGRES_PASSWORD=${TR_DB_PASSWORD:-traduora}
- POSTGRES_DB=${TR_DB_DATABASE:-traduora}
ports:
- '${TR_DB_PORT:-5432}:5432'
volumes:
- 'traduora-db:/var/lib/postgresql/data'
Sources: docker-compose.yaml:18-30
MySQL
To use MySQL, the docker-compose.mysql.yaml file overrides the db service definition. It switches the image to mysql:5.7 and maps the appropriate environment variables for MySQL.
# docker-compose.mysql.yaml:3-13
services:
db:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=${TR_DB_PASSWORD:-traduora}
- MYSQL_DATABASE=${TR_DB_DATABASE:-traduora}
- MYSQL_USER=${TR_DB_USER:-traduora}
- MYSQL_PASSWORD=${TR_DB_PASSWORD:-traduora}
ports:
- '${TR_DB_PORT:-3306}:3306'
volumes:
- 'traduora-db:/var/lib/mysql'
Sources: docker-compose.mysql.yaml:3-13
PostgreSQL (Explicit)
Similarly, docker-compose.postgres.yaml can be used to explicitly define the PostgreSQL service, which is useful for ensuring consistency or making specific PostgreSQL-related overrides.
Sources: docker-compose.postgres.yaml
Entrypoint Script
The docker-entrypoint.compose.sh script is the entrypoint for the traduora service in the compose environment. Its primary function is to wait for the database to become available by using the wait-for-it.sh script before executing the main application command. This prevents the application from crashing if it starts before the database is ready to accept connections.
This flowchart shows the logic of the entrypoint script.
Sources: docker-entrypoint.compose.sh:3-7
Environment Variables
The Docker deployment is configured using environment variables. These can be set in a .env file or directly in the shell. The following table summarizes the key variables.
| Variable | docker-compose.yaml Default | docker-compose.mysql.yaml Default | Description |
|---|---|---|---|
TR_DB_TYPE | postgres | mysql | Specifies the database type. |
TR_DB_HOST | db | db | The hostname of the database service. |
TR_DB_PORT | 5432 | 3306 | The port for the database service. |
TR_DB_USER | traduora | traduora | The database username. |
TR_DB_PASSWORD | traduora | traduora | The database password. |
TR_DB_DATABASE | traduora | traduora | The name of the database. |
TR_PORT | 8080 | 8080 | The port on which the Traduora application listens. |
TR_SECRET | changeme | changeme | A secret key for signing JWTs. Must be changed in production. |
TR_ADMIN_EMAIL | local.admin@ever.co | local.admin@ever.co | Email for the default admin user. |
TR_ADMIN_PASSWORD | sTr0ngP@ssw0rd!2025 | sTr0ngP@ssw0rd!2025 | Password for the default admin user. |
TR_SEED_DATA | true | true | If true, automatically runs seed scripts on startup. |
Sources: docker-compose.yaml:13-16, docker-compose.mysql.yaml:5-8, README.md:83-93, README.md:110-112
Kubernetes Deployment
For container orchestration environments like Kubernetes, a similar configuration is used. The deploy/k8s/traduora-preview.yaml file provides an example of deploying Traduora and MySQL. It defines a Deployment for Traduora using the everco/ever-traduora:latest image and a ConfigMap and Secret to manage environment variables, mirroring the setup in Docker Compose. This demonstrates the portability of the containerized application.
Key elements from the Kubernetes deployment manifest:
- Image:
everco/ever-traduora:latest - Container Port:
8080 - Probes: Liveness and Readiness probes are configured for the
/healthendpoint. - Environment Variables: Managed via
ConfigMapandSecretresources, includingTR_DB_HOST,TR_DB_DATABASE,TR_SECRET, etc.
Sources: deploy/k8s/traduora-preview.yaml:28-63, deploy/k8s/traduora-preview.yaml:83-102