Fix database connection issues and serve photos app at root domain

This commit is contained in:
Andreas Düren 2025-03-16 23:23:32 +01:00
parent 31def9585a
commit 6f6741dfb5

View File

@ -426,16 +426,10 @@ cat > /app/data/public/index.html <<EOT
<title>Ente</title>
<script src="/config.js"></script>
<script src="/debug.js"></script>
<script>
// Redirect to the photos app after a brief delay
setTimeout(function() {
window.location.href = "/photos/";
}, 300);
</script>
</head>
<body>
<h1>Loading Ente...</h1>
<p>You will be redirected automatically.</p>
<h1>Ente</h1>
<p>Welcome to Ente!</p>
<p><a href="/debug">Debug Information</a></p>
</body>
</html>
@ -527,34 +521,26 @@ cat > /app/data/caddy/Caddyfile <<EOT
reverse_proxy localhost:$API_PORT
}
# Root handler
handle / {
root * /app/data/public
file_server
}
# Server web apps
handle /photos* {
uri replace /photos /
# Serve photos app at the root
handle /* {
root * /app/web/photos
# Inject config script
handle_path /* {
@html {
path *.html index.html
not path */assets/* */static/* */img/* */css/* */js/*
}
header @html Content-Type "text/html; charset=utf-8"
# Use rewrite to modify HTML content
@isIndex path /index.html
rewrite @isIndex /photos-injected.html
file_server
@html {
path *.html index.html
not path */assets/* */static/* */img/* */css/* */js/*
}
header @html Content-Type "text/html; charset=utf-8"
# Use rewrite to modify HTML content
@isIndex path /index.html
rewrite @isIndex /photos-injected.html
file_server
}
# Accounts app
handle /accounts* {
uri replace /accounts /
root * /app/web/accounts
@ -575,6 +561,7 @@ cat > /app/data/caddy/Caddyfile <<EOT
}
}
# Auth app
handle /auth* {
uri replace /auth /
root * /app/web/auth
@ -595,6 +582,7 @@ cat > /app/data/caddy/Caddyfile <<EOT
}
}
# Cast app
handle /cast* {
uri replace /cast /
root * /app/web/cast
@ -778,7 +766,7 @@ if [ -d "$SERVER_DIR/cmd/museum" ]; then
# Execute as the cloudron user but use a proper script instead of env cd
cat > /tmp/run_migration.sh <<EOF
#!/bin/bash
cd "$SERVER_DIR" && go run cmd/museum/main.go db force 25
cd "$SERVER_DIR" && ENTE_PG_DSN="postgres://${MUSEUM_DB_USER}:${MUSEUM_DB_PASSWORD}@${MUSEUM_DB_HOST}:${MUSEUM_DB_PORT}/${MUSEUM_DB_NAME}?sslmode=disable" go run cmd/museum/main.go db force 25
EOF
chmod +x /tmp/run_migration.sh
@ -830,7 +818,7 @@ elif [ -d "$SERVER_DIR/cmd/museum" ]; then
# Create a startup script
cat > /tmp/run_server.sh <<EOF
#!/bin/bash
cd "$SERVER_DIR" && go run cmd/museum/main.go serve
cd "$SERVER_DIR" && ENTE_PG_DSN="postgres://${MUSEUM_DB_USER}:${MUSEUM_DB_PASSWORD}@${MUSEUM_DB_HOST}:${MUSEUM_DB_PORT}/${MUSEUM_DB_NAME}?sslmode=disable" go run cmd/museum/main.go serve
EOF
chmod +x /tmp/run_server.sh
@ -845,6 +833,7 @@ EOF
MUSEUM_DB_USER="$MUSEUM_DB_USER" \
MUSEUM_DB_PASSWORD="$MUSEUM_DB_PASSWORD" \
MUSEUM_DB_NAME="$MUSEUM_DB_NAME" \
ENTE_PG_DSN="postgres://${MUSEUM_DB_USER}:${MUSEUM_DB_PASSWORD}@${MUSEUM_DB_HOST}:${MUSEUM_DB_PORT}/${MUSEUM_DB_NAME}?sslmode=disable" \
ENTE_LOG_LEVEL=debug \
bash /tmp/run_server.sh > /app/data/logs/museum.log 2>&1 &
SERVER_PID=$!