mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 00:27:11 +01:00
feat(config): adjust to upsun
This commit is contained in:
parent
dc06a9c3e1
commit
d93c78a0ec
4 changed files with 84 additions and 41 deletions
50
.environment
50
.environment
|
|
@ -1,30 +1,32 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# This script can be a starting point to convert
|
# Upsun Environment Configuration
|
||||||
# PLATFORM_RELATIONSHIPS into another environment variable
|
# Dieses Script erstellt die DATABASE_URL aus den Upsun-Umgebungsvariablen
|
||||||
# Many CMS systems use a DATABASE_URL to connect to the database
|
|
||||||
# Feel free to use this as inspiration
|
|
||||||
|
|
||||||
getRelationshipInfo() {
|
# Upsun stellt Relationship-Informationen über Umgebungsvariablen bereit
|
||||||
RELATIONSHIP_NAME="$1"
|
# Format: <RELATIONSHIP_NAME>_<PROPERTY> (uppercase, - wird zu _)
|
||||||
PROPERTY="$2"
|
# Beispiel: POSTGRESDATABASE_HOST, POSTGRESDATABASE_PORT, etc.
|
||||||
JQ_STR="to_entries[] | select(.key==\"$RELATIONSHIP_NAME\") | .value[].$PROPERTY"
|
|
||||||
CMD="echo $PLATFORM_RELATIONSHIPS | base64 -d | jq -r '$JQ_STR'"
|
|
||||||
eval $CMD
|
|
||||||
}
|
|
||||||
|
|
||||||
# choose the name of the relationship to parse, feel free to alter this
|
# Prüfen ob wir auf Upsun/Platform.sh laufen
|
||||||
RELATIONSHIP="postgresdatabase"
|
if [ -n "$PLATFORM_RELATIONSHIPS" ]; then
|
||||||
DB_DATABASE="main"
|
# Upsun/Platform.sh Umgebung - Relationships parsen
|
||||||
|
getRelationshipInfo() {
|
||||||
|
RELATIONSHIP_NAME="$1"
|
||||||
|
PROPERTY="$2"
|
||||||
|
JQ_STR="to_entries[] | select(.key==\"$RELATIONSHIP_NAME\") | .value[].$PROPERTY"
|
||||||
|
CMD="echo $PLATFORM_RELATIONSHIPS | base64 -d | jq -r '$JQ_STR'"
|
||||||
|
eval $CMD
|
||||||
|
}
|
||||||
|
|
||||||
# Extract the information we need
|
RELATIONSHIP="postgresdatabase"
|
||||||
DB_TYPE=$(getRelationshipInfo "$RELATIONSHIP" 'scheme')
|
DB_DATABASE="main"
|
||||||
DB_USERNAME=$(getRelationshipInfo "$RELATIONSHIP" 'username')
|
|
||||||
DB_HOST=$(getRelationshipInfo "$RELATIONSHIP" 'host')
|
|
||||||
DB_PASS=$(getRelationshipInfo "$RELATIONSHIP" 'password')
|
|
||||||
DB_PORT=$(getRelationshipInfo "$RELATIONSHIP" 'port')
|
|
||||||
|
|
||||||
# Create your DATABASE_URL variable here
|
DB_USERNAME=$(getRelationshipInfo "$RELATIONSHIP" 'username')
|
||||||
export DATABASE_URL="postgresql://$DB_USERNAME:$DB_PASS@$DB_HOST:$DB_PORT/$DB_DATABASE"
|
DB_HOST=$(getRelationshipInfo "$RELATIONSHIP" 'host')
|
||||||
|
DB_PASS=$(getRelationshipInfo "$RELATIONSHIP" 'password')
|
||||||
|
DB_PORT=$(getRelationshipInfo "$RELATIONSHIP" 'port')
|
||||||
|
|
||||||
# So now we have postgresql://user:@db_mysql.internal:3306/main
|
export DATABASE_URL="postgresql://$DB_USERNAME:$DB_PASS@$DB_HOST:$DB_PORT/$DB_DATABASE"
|
||||||
# echo "$DATABASE_URL" #only echo to test since it will expose the credentials
|
fi
|
||||||
|
|
||||||
|
# Hinweis: Die DATABASE_URL kann auch direkt in den Upsun-Projekteinstellungen
|
||||||
|
# als Umgebungsvariable gesetzt werden, was die bevorzugte Methode ist.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
"https://{default}/":
|
|
||||||
type: upstream
|
|
||||||
upstream: "app:http"
|
|
||||||
|
|
||||||
# "https://www.{default}/":
|
|
||||||
# type: redirect
|
|
||||||
# to: "https://{default}/"
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
# The name given to the PostgreSQL service (lowercase alphanumeric only).
|
|
||||||
dbpostgres:
|
|
||||||
# The type of your service (postgresql), which uses the format
|
|
||||||
# 'type:version'. Be sure to consult the PostgreSQL documentation
|
|
||||||
# (https://docs.platform.sh/add-services/postgresql.html#supported-versions)
|
|
||||||
# when choosing a version. If you specify a version number which is not available,
|
|
||||||
# the CLI will return an error.
|
|
||||||
type: postgresql:15
|
|
||||||
# The disk attribute is the size of the persistent disk (in MB) allocated to the service.
|
|
||||||
disk: 4864
|
|
||||||
58
.upsun/config.yaml
Normal file
58
.upsun/config.yaml
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
# Upsun Konfiguration für Umami Analytics
|
||||||
|
# https://docs.upsun.com/configuration.html
|
||||||
|
|
||||||
|
applications:
|
||||||
|
app:
|
||||||
|
# Die Anwendung verwendet Node.js 22
|
||||||
|
stack:
|
||||||
|
- 'nodejs:22'
|
||||||
|
|
||||||
|
# Build-Konfiguration
|
||||||
|
build:
|
||||||
|
flavor: none
|
||||||
|
|
||||||
|
# Build- und Deploy-Hooks
|
||||||
|
hooks:
|
||||||
|
build: |
|
||||||
|
set -e
|
||||||
|
corepack enable
|
||||||
|
corepack prepare pnpm@latest --activate
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
pnpm build
|
||||||
|
deploy: |
|
||||||
|
set -e
|
||||||
|
pnpm update-db
|
||||||
|
|
||||||
|
# Writable Mounts für Uploads
|
||||||
|
mounts:
|
||||||
|
'web/uploads':
|
||||||
|
source: storage
|
||||||
|
source_path: uploads
|
||||||
|
|
||||||
|
# Webserver-Konfiguration
|
||||||
|
web:
|
||||||
|
commands:
|
||||||
|
start: 'pnpm start'
|
||||||
|
|
||||||
|
# Beziehung zur PostgreSQL-Datenbank
|
||||||
|
relationships:
|
||||||
|
postgresdatabase: 'dbpostgres:postgresql'
|
||||||
|
|
||||||
|
# Service-Definitionen
|
||||||
|
services:
|
||||||
|
dbpostgres:
|
||||||
|
type: postgresql:16
|
||||||
|
configuration:
|
||||||
|
resources:
|
||||||
|
disk: 5120
|
||||||
|
|
||||||
|
# Routen-Konfiguration
|
||||||
|
routes:
|
||||||
|
'https://{default}/':
|
||||||
|
type: upstream
|
||||||
|
upstream: 'app:http'
|
||||||
|
|
||||||
|
# Optional: www-Redirect aktivieren
|
||||||
|
# 'https://www.{default}/':
|
||||||
|
# type: redirect
|
||||||
|
# to: 'https://{default}/'
|
||||||
Loading…
Add table
Add a link
Reference in a new issue