Docker Deployment
Relevant source files
The following files were used as context for generating this wiki page:
Docker deployment for the Rosy Tax Processor provides a containerized environment to execute the AI-powered tax document processing system. This approach ensures consistency across different environments, encapsulating all necessary dependencies including Python 3.12, Flask, and heavy machine learning models required for semantic field mapping and OCR.
The deployment infrastructure is designed to support the full Processing Pipeline, ranging from file ingestion and document classification to final PDF generation. By utilizing Docker, the system can be easily integrated into CI/CD workflows, such as GitHub Actions, ensuring that every push or pull request is validated within a standardized container.
Sources: README.md:29-35, README.md:143-150
Image Configuration and Build Process
The Docker image for Rosy is built using a standard Dockerfile (referenced in documentation) that installs the requirements specified in the project. The environment is configured to run the Flask backend, which serves as the primary interface for the application.
Build and Run Commands
To deploy the system using Docker, the following commands are utilized:
| Action | Command | Description |
|---|---|---|
| Build | docker build -t rosy-tax-processor . | Packages the application and dependencies into an image. |
| Run | docker run -p 5000:5000 rosy-tax-processor | Launches the container and maps the internal Flask port. |
Sources: README.md:144-148, backend.py:157
Dependency Management
The containerized environment includes several critical libraries and optional OCR tools:
- Core Dependencies:
pytest,reportlab,pdfrw, andsentence-transformers. - Optional OCR:
pytesseractandPillowfor image processing (PNG, JPG). - PDF Extraction:
PyMuPDFandpdfminer.six.
Sources: requirements.txt:1-12
Containerized Architecture
The Docker container encapsulates the entire application logic, from the frontend assets to the backend processing engine.
The diagram shows the high-level relationship between the client and the internal container components.
Sources: README.md:38-57, backend.py:12-25
Deployment Lifecycle
When the container starts, it initializes the Flask server (backend.py) on port 5000. On the first run, the container may download AI models (approximately 500MB) from external repositories for the sentence-transformers library used in semantic mapping.
Initialization and Resource Usage
- First Run: 1-2 minutes due to model downloads.
- Subsequent Runs: High speed (< 3 seconds per document).
- Storage: Uses temporary directories (
tempfile.mkdtemp) with the prefixrosy_upload_orrosy_final_for processing.
Sources: SETUP.md:58-61, backend.py:59, backend.py:102
CI/CD Integration
The Docker configuration is integrated with GitHub Actions to automate the testing and deployment process. This ensures that the 14-test suite, covering parsing, tax calculation, and security, is executed in a clean container environment before any deployment.
Sources: README.md:33-34, README.md:83-84
Security and Isolation within Docker
Deployment via Docker enhances security by isolating the application environment. The system implements several security layers that are maintained within the container:
- File Sanitization: All uploaded files are sanitized using
re.sub(r'[^A-Za-z0-9._-]', '_', base)to prevent path traversal within the container's file system. - Resource Limits: A maximum upload limit of 5MB (
MAX_UPLOAD_BYTES) is enforced at the application level to prevent resource exhaustion. - Local Processing: All tax processing occurs locally within the container; no data is sent to external servers after the initial model download.
- Automatic Cleanup: Temporary files created during the pipeline execution in
pipeline.pyandbackend.pyare removed after the processing is complete.
Sources: security.py:10-17, SETUP.md:65-67, backend.py:84-88
Summary
The Docker deployment for Rosy Tax Processor provides a robust, portable, and secure method for running the automated tax system. By containerizing the Flask backend and its associated AI models, the project ensures that the complex document parsing and tax calculation pipeline remains consistent across development and production environments. This deployment model supports the project's goal of offering a 100% complete prototype ready for demonstration or further integration.