Repository navigation
chore(deploy): add Render.com deployment configuration #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Render.com blueprint for ClimateVision | ||
| # Deploys a single web service that serves both the FastAPI backend | ||
| # and the built React frontend. | ||
| # | ||
| # To deploy: | ||
| # 1. Create a Render account at https://render.com | ||
| # 2. Install the Render CLI: https://render.com/docs/cli | ||
| # 3. Run: ./scripts/setup_render_secrets.sh | ||
| # 4. Push this file to GitHub; Render will detect it via Blueprint. | ||
|
|
||
| services: | ||
| - type: web | ||
| name: climatevision-green | ||
| runtime: docker | ||
| plan: free | ||
| dockerfilePath: ./Dockerfile | ||
| startCommand: ./scripts/render_entrypoint.sh | ||
| envVars: | ||
| - key: PYTHONUNBUFFERED | ||
| value: "1" | ||
| - key: OMP_NUM_THREADS | ||
| value: "1" | ||
| - key: PORT | ||
| value: "8000" | ||
| - key: DATABASE_URL | ||
| value: sqlite:///app/outputs/climatevision.sqlite3 | ||
| - key: CLIMATEVISION_ALLOW_DEV_KEY | ||
| value: "0" | ||
| - key: CLIMATEVISION_CORS_ORIGINS | ||
| value: "https://climatevision.green,https://www.climatevision.green" | ||
| # Set these via ./scripts/setup_render_secrets.sh | ||
| - key: GEE_SERVICE_ACCOUNT | ||
| sync: false | ||
| - key: GEE_SERVICE_ACCOUNT_KEY_JSON | ||
| sync: false | ||
| - key: GEE_PROJECT_ID | ||
| sync: false | ||
| - key: API_SECRET_KEY | ||
| generateValue: true | ||
| - key: ANTHROPIC_API_KEY | ||
| sync: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/bash | ||
| # Render.com entrypoint. | ||
| # Writes the GEE service-account key from the environment into a file, | ||
| # then starts the ClimateVision API. | ||
|
|
||
| set -e | ||
|
|
||
| mkdir -p /app/secrets | ||
|
|
||
| # Render stores file contents in env vars because it does not support secret | ||
| # files on the free tier. Write the JSON key to disk so the app can read it. | ||
| if [ -n "$GEE_SERVICE_ACCOUNT_KEY_JSON" ]; then | ||
| echo "$GEE_SERVICE_ACCOUNT_KEY_JSON" > /app/secrets/gee-key.json | ||
| fi | ||
|
|
||
| # Create writable directories for SQLite and outputs | ||
| mkdir -p /app/outputs /app/data /app/logs | ||
|
|
||
| export PORT="${PORT:-8000}" | ||
|
|
||
| echo "Starting ClimateVision API on port $PORT" | ||
| exec uvicorn climatevision.api.main:app --host 0.0.0.0 --port "$PORT" --workers 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/bin/bash | ||
| # Upload ClimateVision secrets to Render.com. | ||
| # Usage: ./scripts/setup_render_secrets.sh | ||
|
|
||
| set -e | ||
|
|
||
| cd "$(dirname "$0")/.." | ||
|
|
||
| SERVICE_NAME="climatevision-green" | ||
|
|
||
| if ! command -v render &> /dev/null; then | ||
| echo "Error: Render CLI not found. Install it from https://render.com/docs/cli" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -f .env ]; then | ||
| echo "Error: .env file not found. Copy .env.example to .env and fill it in." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -f secrets/gee-key.json ]; then | ||
| echo "Error: secrets/gee-key.json not found. Place your GEE service-account key there." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Uploading secrets to Render service: $SERVICE_NAME" | ||
|
|
||
| # Read values from .env and upload | ||
| while IFS= read -r line || [ -n "$line" ]; do | ||
| # Skip comments and empty lines | ||
| case "$line" in | ||
| \#*|""|*\ #*) continue ;; | ||
| esac | ||
|
|
||
| case "$line" in | ||
| *=*) ;; | ||
| *) continue ;; | ||
| esac | ||
|
|
||
| key="${line%%=*}" | ||
| value="${line#*=}" | ||
| value=$(echo "$value" | sed -e 's/^["'"'"']//' -e 's/["'"'"']$//') | ||
|
|
||
| [ -z "$value" ] && continue | ||
|
|
||
| # Skip the file-path key; we will upload the file contents separately | ||
| if [ "$key" = "GEE_SERVICE_ACCOUNT_KEY" ]; then | ||
| continue | ||
| fi | ||
|
|
||
| echo "Setting $key" | ||
| render env set "$SERVICE_NAME" "$key=$value" --yes | ||
|
|
||
| done < .env | ||
|
|
||
| # Upload the GEE key JSON contents as GEE_SERVICE_ACCOUNT_KEY_JSON | ||
| GEE_KEY_JSON=$(cat secrets/gee-key.json) | ||
| echo "Setting GEE_SERVICE_ACCOUNT_KEY_JSON" | ||
| render env set "$SERVICE_NAME" "GEE_SERVICE_ACCOUNT_KEY_JSON=$GEE_KEY_JSON" --yes | ||
|
|
||
| echo "Done. Verify with: render env list $SERVICE_NAME" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what's failing the
dockerCI job. The build dies here with:buildx failed with: ERROR: failed to solve: process "/bin/sh -c chmod +x scripts/*.sh" did not complete successfully: exit code: 1Root cause:
.dockerignorecontainsscripts/*.sh, so no.shfiles are in the build context.COPY scripts/ ./scripts/brings in the directory without any shell scripts, thenchmod +x scripts/*.shmatches nothing and exits 1.This is also a runtime bug: the final
CMD ["./scripts/render_entrypoint.sh"]would fail since that script is excluded by the same rule, even if the chmod line were removed.Fix: remove (or narrow) the
scripts/*.shentry in.dockerignoresorender_entrypoint.shis included. If you want to keep ignoring the local-only setup scripts, ignore them by name instead (e.g.scripts/setup_*.sh) and let the entrypoint through.