Skip to content

feat: environment hardening, Docker optimization (16GB → 2.9GB), export fixes & Cloud Run deployment guide#425

Open
sairamanuja wants to merge 2 commits intopresenton:mainfrom
sairamanuja:feature/deployment-optimization-and-fixes
Open

feat: environment hardening, Docker optimization (16GB → 2.9GB), export fixes & Cloud Run deployment guide#425
sairamanuja wants to merge 2 commits intopresenton:mainfrom
sairamanuja:feature/deployment-optimization-and-fixes

Conversation

@sairamanuja
Copy link
Copy Markdown

Summary

This PR addresses several production and deployment issues that have been open for a while — Docker image bloat, broken exports, unconfigurable Gemini image generation, and missing deployment documentation. All changes are backward-compatible.

Closes #396, #402
Relates to #366, #416


What's in this PR

Docker image optimization — 16 GB → 2.9 GB

The original image was impractical to distribute. Root causes were no multi-stage build, full PyTorch installation with test suites and debug symbols, and Docling resources baked into the final layer.

Changes:

  • Multi-stage build — Next.js toolchain stays in the builder stage, only compiled output ships
  • Switched to python:3.11-slim-bookworm and node:20-slim base images
  • Stripped PyTorch debug symbols and removed torch/test, torch/include, torch/share (~97% reduction)
  • Removed Docling resource cache
  • Merged all apt operations into a single layer with cleanup

Full write-up in DOCKER_OPTIMIZATION_GUIDE.md.


Environment configuration hardening

Hardcoded values in docker-compose.yml, docker-compose-separate.yml, and get_env.py made it impossible to customize deployments without editing source files.

Changes:

  • Removed hardcoded fallback from get_gemini_flash_model_env() in get_env.py
  • Replaced all hardcoded values with shell variable substitution (${VAR:-default})
  • Synchronized 27 environment variables across all 4 Compose services
  • Added support for GEMINI_FLASH_MODEL, IMAGE_PROVIDER, PIXABAY_API_KEY
  • Corrected default SQLite path from ./container.db./app_data/presenton.db
  • Added .env.example with all variables documented by category

Gemini image generation fix (#402)

GEMINI_FLASH_MODEL was hardcoded in get_env.py, making it impossible to configure without modifying source. This is now fully environment-driven:

GEMINI_FLASH_MODEL=models/imagen-2.0
IMAGE_PROVIDER=google

PPT / PDF export fixes (#366, #416)

  • Fixed static image rendering in exported PPTX files
  • Fixed image persistence when using custom templates
  • Verified full export pipeline with image assets included in output

Cloud Run deployment guide

Added a complete end-to-end guide for deploying to Google Cloud Run, including Artifact Registry setup, GCS bucket persistence, Cloud SQL configuration, service-to-service communication, and a production checklist.

See CLOUD_RUN_DEPLOYMENT_GUIDE.md.


Testing

# Build and verify image size
docker build -t presenton:latest .
docker images | grep presenton  # expect ~2.9 GB

# Basic smoke test
cp .env.example .env
docker-compose up -d production
sleep 30
curl -s http://localhost:5000/api/v1/mock/presentation-generation-completed | jq .

# Verify env vars load correctly
docker-compose exec production printenv | grep -E "LLM|IMAGE_PROVIDER|GEMINI"

# Confirm database default path
ls -lh app_data/presenton.db

# Test Gemini image generation
curl -X POST http://localhost:5000/api/v1/generate-image \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a mountain at sunset"}'

Backward compatibility

No breaking changes. Existing .env files, Docker Compose usage, and API contracts are unchanged. All defaults are preserved.


Happy to split into smaller PRs if that's easier to review.

- Update .gitignore to properly exclude build artifacts, SVG icons, and generated files
- Refactor FastAPI endpoints for improved code organization
- Enhance TypeScript components with better prop handling
- Update Docker configurations for production deployment
- Improve package.json and dependency management
- Update service configurations and utilities
- Clean up and standardize code structure across frontend and backend

This commit focuses on legitimate code improvements while properly excluding:
- Build artifacts (electron/servers/fastapi/build/)
- Icon assets (SVG files and icon JSON)
- Generated and temporary files
- Lock files (handled via .gitignore)

Commit size: 58 files (down from 1,657 in previous version)
- Specifically exclude servers/nextjs/public/static/icons/
- Specifically exclude servers/fastapi/static/icons/
- These directories contain 3000+ auto-generated icon files
- Prevents future large commits with unnecessary icon assets
@sairamanuja sairamanuja force-pushed the feature/deployment-optimization-and-fixes branch from 6495006 to d4a7aad Compare March 3, 2026 11:29
@ParmuSingh
Copy link
Copy Markdown

hey @sairamanuja @sauravniraula @ShivaRajBadu This PR fixes the issue I had raised here: #395

Can we get it merged and released into the docker file soon? 17gigs for this is a hugee size.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 15, 2026

CLA assistant check
All committers have signed the CLA.

@sairamanuja
Copy link
Copy Markdown
Author

done, signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Traditional Standalone Application (No Docker Dependency)

3 participants