-
Notifications
You must be signed in to change notification settings - Fork 0
Sync Upsun skill with latest configuration guidance (a38676782c33) #21
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,130 @@ | ||||||||||||||||||||||||||
| ## 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+ (this example uses nodejs:22 runtime) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| 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
+47
|
||||||||||||||||||||||||||
| export ADMIN_EMAIL='admin@example.com' | |
| export ADMIN_PASSWORD='password' | |
| if [ -z "${ADMIN_EMAIL:-}" ]; then | |
| echo 'ERROR: ADMIN_EMAIL must be provided via an Upsun environment variable or secret before first deploy.' >&2 | |
| exit 1 | |
| fi | |
| if [ -z "${ADMIN_PASSWORD:-}" ]; then | |
| export ADMIN_PASSWORD="$(node -e "const crypto = require('crypto'); const entropy = process.env.PLATFORM_PROJECT_ENTROPY || crypto.randomBytes(32).toString('hex'); process.stdout.write(crypto.createHash('sha256').update(entropy + ':directus-admin').digest('base64').replace(/[^A-Za-z0-9]/g, '').slice(0, 32));")" | |
| echo 'ADMIN_PASSWORD was not provided; a strong password was generated for this bootstrap run. Store a permanent admin password in an Upsun secret to avoid rotation surprises on rebuilds.' >&2 | |
| fi |
| 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)")") | ||||||
| if [ -n "$settings_dir" ]; then | ||||||
| echo >> "$settings_dir"/settings.py "\n# Upsun configuration" | ||||||
|
||||||
| echo >> "$settings_dir"/settings.py "\n# Upsun configuration" | |
| printf '\n# Upsun configuration\n' >> "$settings_dir"/settings.py |
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 heredoc expands
$REDIS_HOST/$REDIS_PORTat build time, but relationship env vars are runtime-only on Upsun (the build hook has no service access). That means the generated.environmentwill contain empty Redis host/port values. Write literal variable references into.environment(escape$or use a quoted heredoc delimiter) so they resolve when.environmentis sourced at runtime.