delphi-docker-demo
A demonstration of containerizing Delphi WebBroker applications with Docker.
- Active · last change 5-30-2025
- ★ 5 on GitHub
README
Delphi Docker Demo
A demonstration project showcasing how to containerize a Delphi WebBroker application using Docker. This project serves as a practical example of running Delphi applications in containers, with a focus on cross-platform compatibility and modern deployment practices.
Features
- Simple WebBroker application with two endpoints:
- Root endpoint (
/): Serves a welcome page - Health endpoint (
/health): Returns application health status in JSON format
- Root endpoint (
- Logging system with configurable log levels
- Cross-platform support (Windows and Linux)
- Docker containerization with proper signal handling
- Automated Docker image building through post-build events
- Volume support for persistent logging
Prerequisites
- Delphi 11 or later
- Windows 10/11 with WSL2 installed
- Docker Desktop with WSL2 integration or Docker cli installed in WSL2
Project Structure
.
????????? Linux64/ # Linux build output directory
??? ????????? Docker/ # Contains the Linux executable
????????? WebModuleUnit1.pas # Main web module with endpoints
????????? LoggerU.pas # Logging implementation
????????? Dockerfile # Docker configuration
????????? build_docker_image.ps1 # PowerShell script for Docker buildBuilding and Running
Local Development
- Open the project in Delphi IDE
- Select the "Docker" build configuration
- Build the project (F9 or Build > Build)
- The post-build event will automatically:
- Clean up old Docker resources
- Build a new Docker image
- Set up proper permissions
Running the Container
docker run -d -p 8080:8080 -v $(pwd)/logs:/app/logs --name=delphi-demo delphi-docker-demo:latestAccessing the Application
- Main page: http://localhost:8080
- Health check: http://localhost:8080/health
Docker Image
The Docker image is available on DockerHub:
docker pull thony/delphi-docker-demo:latestLogging
The application implements a basic logging system:
- Logs are written to the
logsdirectory - Logs can be persisted through Docker volumes
Development Notes
- The project uses a post-build PowerShell script to automate Docker image creation
- Signal handling is implemented for graceful container shutdown
- The application detects whether it's running in a container or interactive mode
- Cross-platform compatibility is maintained through conditional compilation
Contributing
Feel free to submit issues and enhancement requests!

