Setup Unified Dockerfile and staging environment with updated URLs#68
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a multi-stage Dockerfile for both the frontend and backend, configures Docker Compose, adds a staging configuration to the backend settings, and updates database session handling to prioritize the DATABASE_URL environment variable. It also introduces a bloats/ directory containing various temporary scripts and documents. Key feedback includes resolving a potential runtime crash by replacing postgres:// with postgresql:// in the database URL, removing a redundant uv installation in the final backend Docker stage, avoiding hardcoded staging URLs in the configuration, fixing a security misconfiguration in ALLOWED_HOSTS, and removing the temporary bloats/ directory from version control to prevent repository bloat and potential secret leaks.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if os.getenv("DATABASE_URL"): | ||
| SQLALCHEMY_DATABASE_URL = os.getenv("DATABASE_URL") |
There was a problem hiding this comment.
Many cloud platforms (such as Render, Heroku, and Railway) provide the database connection string via the DATABASE_URL environment variable using the postgres:// protocol prefix. However, SQLAlchemy 1.4+ and 2.0+ do not support postgres:// directly and will raise a NoSuchModuleError at runtime. It is highly recommended to automatically replace postgres:// with postgresql:// to ensure compatibility and prevent startup crashes on these platforms.
| if os.getenv("DATABASE_URL"): | |
| SQLALCHEMY_DATABASE_URL = os.getenv("DATABASE_URL") | |
| database_url = os.getenv("DATABASE_URL") | |
| if database_url: | |
| SQLALCHEMY_DATABASE_URL = database_url.replace("postgres://", "postgresql://", 1) |
| RUN pip install --no-cache-dir uv | ||
|
|
||
| COPY --from=backend-builder /app/.venv /app/.venv |
There was a problem hiding this comment.
Installing uv in the final backend stage is redundant because the virtual environment (/app/.venv) containing all dependencies has already been built in the backend-builder stage and copied over. Since the PATH is updated to prioritize /app/.venv/bin, the application will run successfully without uv in the final image. Removing this step reduces the final image size and speeds up the build process.
COPY --from=backend-builder /app/.venv /app/.venv
| class StagingConfig(BaseConfig): | ||
| FRONTEND_URI: str = "https://taimakoai.onrender.com" | ||
| FRONTEND_REDIRECT_URI: str = "https://taimakoai.onrender.com/auth/callback" | ||
|
|
||
| CORS_ORIGINS: List[str] = [ | ||
| "https://taimakoai.onrender.com", | ||
| ] |
There was a problem hiding this comment.
Hardcoding the staging frontend and backend URLs directly in StagingConfig makes the configuration inflexible. If you deploy staging to a different URL or use dynamic pull request preview environments (e.g., on Render), these hardcoded values will break the application. It is better to load them from environment variables with the current staging URLs as fallbacks, similar to how ProductionConfig is implemented.
| class StagingConfig(BaseConfig): | |
| FRONTEND_URI: str = "https://taimakoai.onrender.com" | |
| FRONTEND_REDIRECT_URI: str = "https://taimakoai.onrender.com/auth/callback" | |
| CORS_ORIGINS: List[str] = [ | |
| "https://taimakoai.onrender.com", | |
| ] | |
| class StagingConfig(BaseConfig): | |
| FRONTEND_URI: str = os.getenv("FRONTEND_STAGING_URI", "https://taimakoai.onrender.com") | |
| FRONTEND_REDIRECT_URI: str = f"{os.getenv('FRONTEND_STAGING_URI', 'https://taimakoai.onrender.com')}/auth/callback" | |
| CORS_ORIGINS: List[str] = [ | |
| os.getenv("FRONTEND_STAGING_URI", "https://taimakoai.onrender.com"), | |
| ] |
| ALLOWED_HOSTS: List[str] = [ | ||
| "taimako.onrender.com", | ||
| "taimakoai.onrender.com", | ||
| ] |
There was a problem hiding this comment.
The ALLOWED_HOSTS configuration is used by the backend's trusted host middleware to validate the incoming Host header. It should only contain the domain(s) where the backend application itself is hosted (e.g., taimako.onrender.com). Including the frontend's domain (taimakoai.onrender.com) in the backend's ALLOWED_HOSTS is a security misconfiguration, as the frontend runs on a completely separate server/container and should not be routing host headers to the backend.
ALLOWED_HOSTS: List[str] = [
"taimako.onrender.com",
]| **/.env.* | ||
|
|
||
| # Misc | ||
| **/bloats |
There was a problem hiding this comment.
The bloats/ directory is added to .dockerignore, which correctly prevents it from being copied into the Docker images. However, committing temporary scratchpad scripts, draft proposals, and sensitive files (such as security_incident_report.md and emergent_ventures_proposal.md) to the Git repository is a bad practice. It increases repository bloat and risks leaking sensitive information. It is highly recommended to remove the bloats/ directory from version control entirely and add it to .gitignore.
- Kept DATABASE_URL priority fix and staging config (this branch) - Kept lint fixes: imports at top, unused var removals (this branch) - Brought in WhatsApp, payments, subscription, product features (main) - Brought in new models, migrations, routes, test suite expansion (main) - Deleted leftover copy files (main copy.py, test_api.py) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 29802212 | Triggered | Generic CLI Secret | 1c0a69f | backend/scripts/create_admin.py | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Test had placeholder api.staging.taimako.ai URLs; actual config defaults to the Render deployment URLs for staging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
No description provided.