-
Notifications
You must be signed in to change notification settings - Fork 0
Sync Upsun skill with latest configuration guidance (a38676782c33) #22
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,126 @@ | ||||||||||||
| ## Directus Application Configuration | ||||||||||||
|
|
||||||||||||
| Reference configuration for Directus applications on Upsun. | ||||||||||||
|
|
||||||||||||
| **Framework Priority**: Use Directus-specific configuration instead of generic Node.js guidance when both apply. | ||||||||||||
|
|
||||||||||||
| **Minimum Requirements**: Node.js 18+ required for Directus compatibility | ||||||||||||
|
|
||||||||||||
| **Template Usage**: Adapt database service and authentication configuration to project requirements. Exclude explanatory comments from production configurations. | ||||||||||||
|
|
||||||||||||
| ```yaml | ||||||||||||
| applications: | ||||||||||||
| directus: | ||||||||||||
| type: nodejs:22 | ||||||||||||
|
|
||||||||||||
| build: | ||||||||||||
| flavor: none | ||||||||||||
|
|
||||||||||||
| hooks: | ||||||||||||
| build: | | ||||||||||||
| set -ex | ||||||||||||
| npm install | ||||||||||||
| npm run argon2-rebuild | ||||||||||||
|
|
||||||||||||
| # Create .environment file with dynamic variables | ||||||||||||
| cat > .environment <<EOF | ||||||||||||
| CACHE_ENABLED=true | ||||||||||||
| CACHE_STORE=redis | ||||||||||||
| REDIS_HOST=$REDIS_HOST | ||||||||||||
| REDIS_PORT=$REDIS_PORT | ||||||||||||
| RATE_LIMITER_ENABLED=true | ||||||||||||
| RATE_LIMITER_STORE=redis | ||||||||||||
| RATE_LIMITER_REDIS_HOST=$REDIS_HOST | ||||||||||||
| RATE_LIMITER_REDIS_PORT=$REDIS_PORT | ||||||||||||
| KEY=$PLATFORM_PROJECT_ENTROPY | ||||||||||||
| SECRET=$PLATFORM_PROJECT_ENTROPY | ||||||||||||
| EOF | ||||||||||||
|
|
||||||||||||
| deploy: | | ||||||||||||
| set -ex | ||||||||||||
| if [ ! -f var/upsun.installed ]; then | ||||||||||||
| echo 'Bootstrapping Directus on first deploy...' | ||||||||||||
|
|
||||||||||||
| export PROJECT_NAME='Directus on Upsun' | ||||||||||||
| export ADMIN_EMAIL='admin@example.com' | ||||||||||||
| export ADMIN_PASSWORD='password' | ||||||||||||
|
Comment on lines
+45
to
+46
|
||||||||||||
| export ADMIN_EMAIL='admin@example.com' | |
| export ADMIN_PASSWORD='password' | |
| : "${ADMIN_EMAIL:?Set ADMIN_EMAIL as an Upsun environment variable or secret before first deploy}" | |
| : "${ADMIN_PASSWORD:?Set ADMIN_PASSWORD as an Upsun environment variable or secret before first deploy}" | |
| export ADMIN_EMAIL ADMIN_PASSWORD |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,93 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Django Application Configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Reference configuration for Django web applications on Upsun. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Framework Variants: For Django derivatives (nanodjango, microdjango), adapt management commands accordingly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template usage: Customize this configuration for project-specific requirements. Do not include explanatory comments in production configurations. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| applications: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| site: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: python:3.13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dependencies: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| python3: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv: '*' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hooks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| build: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -ex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv sync --frozen --no-dev --no-managed-python | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Auto-detect WSGI module name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export WSGI_NAME=$(basename "$(dirname "$(find . -maxdepth 4 -path './.*' -prune -o -name wsgi.py -print | head -n1)")") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -z "$WSGI_NAME" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo >&2 'Failed to find WSGI module name' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Configure Django settings for Upsun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export settings_dir=$(basename "$(dirname "$(find . -Maxdepth 4 -path './.*' -prune -o -name settings.py -print | head -n1)")") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export settings_dir=$(basename "$(dirname "$(find . -Maxdepth 4 -path './.*' -prune -o -name settings.py -print | head -n1)")") | |
| export settings_dir=$(basename "$(dirname "$(find . -maxdepth 4 -path './.*' -prune -o -name settings.py -print | head -n1)")") |
Copilot
AI
Apr 21, 2026
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.
The build hook appends ALLOWED_HOSTS = ["*"] to settings.py, which disables host header validation and is unsafe for production. Prefer deriving the allowed host(s) from the primary route at runtime, or setting a narrow default and instructing users to configure it explicitly.
| echo >> "$settings_dir"/settings.py "\n# Upsun configuration" | |
| echo >> "$settings_dir"/settings.py 'ALLOWED_HOSTS = ["*"]' | |
| cat >> "$settings_dir"/settings.py <<'EOF' | |
| # Upsun configuration | |
| import base64 | |
| import json | |
| import os | |
| def _upsun_allowed_hosts(): | |
| routes = os.environ.get("PLATFORM_ROUTES") | |
| if not routes: | |
| return ["localhost", "127.0.0.1", "[::1]"] | |
| try: | |
| decoded = base64.b64decode(routes).decode("utf-8") | |
| route_map = json.loads(decoded) | |
| except Exception: | |
| return ["localhost", "127.0.0.1", "[::1]"] | |
| hosts = [] | |
| for url in route_map.keys(): | |
| try: | |
| host = url.split("://", 1)[1].split("/", 1)[0] | |
| if host: | |
| hosts.append(host) | |
| except Exception: | |
| continue | |
| return hosts or ["localhost", "127.0.0.1", "[::1]"] | |
| ALLOWED_HOSTS = _upsun_allowed_hosts() | |
| EOF |
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.
The build hook writes
.environmentusing an unquoted heredoc, so$REDIS_HOST/$REDIS_PORTwill be expanded during the build phase (when relationship variables are not available) and end up empty at runtime. Write these lines in a way that defers expansion to runtime (e.g., quote the heredoc delimiter or escape$), and ensure variables meant for the app process are exported in.environment.