Installation Guide
This guide covers everything you need to get the Document Template Processing Service up and running.
Prerequisites
- Docker and Docker Compose (recommended)
- OR Python 3.12+ (for manual installation)
Quick Start with Docker Compose (Recommended)
The easiest way to get started is using Docker Compose, which sets up both the service and Gotenberg automatically.
- Clone the repository:
git clone <repository-url> cd document-templating-service
- Start the services:
docker compose up -d
- Verify the installation:
- Health check: http://localhost:8000/
- Stop the services:
# Stop services docker compose stop # Stop and remove services docker compose down
Manual Installation
Step 1: Setup Gotenberg
Gotenberg is required for PDF conversion. Start a Gotenberg instance:
docker run --name gotenberg -d -p 3000:3000 gotenberg/gotenberg:8
Step 2: Setup the Python Service
- Clone and navigate to the project:
git clone <repository-url> cd document-templating-service
- Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # Linux/Mac # or venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
- Set environment variables:
export GOTENBERG_API_URL=http://localhost:3000
- Start the service:
uvicorn main:app --host 0.0.0.0 --port 8000
Docker Build from Source
- Build the Docker image:
docker build -t document-template-processing-service .
- Run the container:
docker run -d -p 8000:8000 -e GOTENBERG_API_URL=http://host.docker.internal:3000 --name dtps document-template-processing-service
Kubernetes Deployment
For production deployments, Kubernetes manifests are available in the k8s/
directory.
- Create the namespace:
kubectl apply -f k8s/namespace.yaml
- Deploy the services:
kubectl apply -f k8s/gotenberg -f k8s/document-template-processing
- Access the service:
kubectl port-forward svc/document-template-processing 8000:8000 -n utils
Cloud Deployment Notes
Google Cloud Run / Similar Platforms
For cloud deployments, use the cloud-optimized Gotenberg image:
# In docker-compose.yaml
services:
gotenberg:
image: gotenberg/gotenberg:8-cloudrun
# ... rest of configuration
This optimized image reduces cold start times and resource usage.
Environment Variables
Variable | Description | Default | Required |
---|---|---|---|
GOTENBERG_API_URL | URL to Gotenberg service | http://host.docker.internal:3000 | Yes |
Verification
After installation, verify everything is working:
- Health Check:
curl http://localhost:8000/
- Test with a sample document: See the Usage Guide for examples.
Troubleshooting
Common Issues
- Connection refused to Gotenberg:
- Ensure Gotenberg is running on the specified port
- Check firewall settings
- Verify the GOTENBERG_API_URL is correct
- Permission errors:
- Ensure Docker daemon is running
- Check user permissions for Docker
- Port already in use:
- Change the port mapping:
-p 8001:8000
- Check what’s using the port:
netstat -tulpn | grep :8000
- Change the port mapping:
Getting Help
- Check the Usage Guide for service usage examples
- Review the main README
- Open an issue on the GitHub repository