Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
sairamanuja wants to merge 1 commit 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 1 commit intopresenton:mainfrom
sairamanuja:feature/deployment-optimization-and-fixes

Conversation

@sairamanuja
Copy link

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.

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)

1 participant