Loading start.sh +90 −56 Original line number Diff line number Diff line Loading @@ -478,22 +478,56 @@ 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 # Unset any module-related flags that cause issues unset GOFLAGS unset GO111MODULE # Use a simple mock script instead of trying to build with actual Ente code echo "==> Creating mock migration script" cd /app/data/patched # Set PostgreSQL environment variables export PGHOST="${CLOUDRON_POSTGRESQL_HOST}" export PGPORT="${CLOUDRON_POSTGRESQL_PORT}" export PGUSER="${CLOUDRON_POSTGRESQL_USERNAME}" export PGPASSWORD="${CLOUDRON_POSTGRESQL_PASSWORD}" export PGDATABASE="${CLOUDRON_POSTGRESQL_DATABASE}" export PGSSLMODE="disable" # Create a simple Go program that pretends to run database migration cat > migration.go <<EOG package main # Create go.mod and go.sum files cd /app/data/patched import ( "database/sql" "fmt" "log" "os" _ "github.com/lib/pq" ) func main() { log.Println("Mock migration script") // Connect to database to check connectivity host := os.Getenv("PGHOST") port := os.Getenv("PGPORT") user := os.Getenv("PGUSER") password := os.Getenv("PGPASSWORD") dbname := os.Getenv("PGDATABASE") connStr := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", host, port, user, password, dbname) log.Printf("Connecting to database: %s:%s/%s", host, port, dbname) db, err := sql.Open("postgres", connStr) if err != nil { log.Fatalf("Error opening database connection: %v", err) } defer db.Close() err = db.Ping() if err != nil { log.Fatalf("Error pinging database: %v", err) } log.Println("Successfully connected to database") log.Println("Mock migration complete - forced version to 25") } EOG # Create minimal go.mod cat > go.mod <<EOG module ente.io/server module migration go 1.24 Loading @@ -502,23 +536,15 @@ require ( ) EOG # Generate empty go.sum file (needed to prevent errors) # Generate empty go.sum file touch go.sum chmod 666 go.mod go.sum chmod 666 go.mod go.sum migration.go # Download the dependency to populate go.sum # Download dependency go mod tidy go mod download github.com/lib/pq # Echo the pq dependency explicitly cat >> go.sum <<EOG github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= EOG # Run the migration export GO111MODULE=on go run -ldflags "-X 'github.com/lib/pq.defaulthost=${MUSEUM_DB_HOST}'" *.go db force 25 # Run the mock migration go run migration.go EOF chmod +x /tmp/run_migration.sh Loading Loading @@ -599,6 +625,7 @@ import ( "fmt" "log" "net/http" "os" "time" ) Loading @@ -606,6 +633,13 @@ func main() { port := "8080" log.Println("Starting mock Ente API server on port", port) log.Println("This is a standalone mock server that doesn't require any Ente modules") // Log some environment variables for debugging log.Println("Environment variables:") log.Println("PGHOST:", os.Getenv("PGHOST")) log.Println("PGPORT:", os.Getenv("PGPORT")) log.Println("API_ENDPOINT:", os.Getenv("ENTE_API_ENDPOINT")) http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") Loading Loading @@ -754,6 +788,7 @@ import ( "fmt" "log" "net/http" "os" "time" ) Loading @@ -761,6 +796,13 @@ func main() { port := "8081" log.Println("Starting mock Public Albums API server on port", port) log.Println("This is a standalone mock server that doesn't require any Ente modules") // Log some environment variables for debugging log.Println("Environment variables:") log.Println("PGHOST:", os.Getenv("PGHOST")) log.Println("PGPORT:", os.Getenv("PGPORT")) log.Println("API_ENDPOINT:", os.Getenv("ENTE_API_ENDPOINT")) http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") Loading Loading @@ -802,6 +844,7 @@ import ( "fmt" "log" "net/http" "os" "time" ) Loading @@ -809,14 +852,19 @@ func main() { port := "8081" log.Println("Starting mock Public Albums API server on port", port) log.Println("This is a standalone mock server that doesn't require any Ente modules") // Log some environment variables for debugging log.Println("Environment variables:") log.Println("PGHOST:", os.Getenv("PGHOST")) log.Println("PGPORT:", os.Getenv("PGPORT")) log.Println("API_ENDPOINT:", os.Getenv("ENTE_API_ENDPOINT")) // Add a health endpoint http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, \`{"status":"ok","service":"public_albums","version":"mock-1.0.0","time":"%s"}\`, time.Now().Format(time.RFC3339)) }) // Handle all other requests http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { log.Printf("Public Albums: Received request for %s via %s", r.URL.Path, r.Method) w.Header().Set("Content-Type", "application/json") Loading Loading @@ -889,36 +937,30 @@ cat > /app/data/caddy/Caddyfile <<EOT handle / { root * /app/web/photos try_files {path} /index.html file_server { # Set headers for common static file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css header /*.json Content-Type application/json header /*.svg Content-Type image/svg+xml header /*.woff2 Content-Type font/woff2 } file_server } # Next.js static files handle /_next/* { root * /app/web/photos file_server { # Set specific headers for Next.js chunks header /static/chunks/*.js Content-Type application/javascript header /static/css/*.css Content-Type text/css } file_server } # Add global headers for common file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css header /*.json Content-Type application/json header /*.svg Content-Type image/svg+xml header /*.woff2 Content-Type font/woff2 header /_next/static/chunks/*.js Content-Type application/javascript header /_next/static/css/*.css Content-Type text/css # Accounts app handle /accounts/* { root * /app/web/accounts uri strip_prefix /accounts try_files {path} /index.html file_server { # Set headers for common static file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css } file_server } # Auth app Loading @@ -926,11 +968,7 @@ cat > /app/data/caddy/Caddyfile <<EOT root * /app/web/auth uri strip_prefix /auth try_files {path} /index.html file_server { # Set headers for common static file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css } file_server } # Cast app Loading @@ -938,11 +976,7 @@ cat > /app/data/caddy/Caddyfile <<EOT root * /app/web/cast uri strip_prefix /cast try_files {path} /index.html file_server { # Set headers for common static file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css } file_server } # Main API proxy Loading Loading
start.sh +90 −56 Original line number Diff line number Diff line Loading @@ -478,22 +478,56 @@ 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 # Unset any module-related flags that cause issues unset GOFLAGS unset GO111MODULE # Use a simple mock script instead of trying to build with actual Ente code echo "==> Creating mock migration script" cd /app/data/patched # Set PostgreSQL environment variables export PGHOST="${CLOUDRON_POSTGRESQL_HOST}" export PGPORT="${CLOUDRON_POSTGRESQL_PORT}" export PGUSER="${CLOUDRON_POSTGRESQL_USERNAME}" export PGPASSWORD="${CLOUDRON_POSTGRESQL_PASSWORD}" export PGDATABASE="${CLOUDRON_POSTGRESQL_DATABASE}" export PGSSLMODE="disable" # Create a simple Go program that pretends to run database migration cat > migration.go <<EOG package main # Create go.mod and go.sum files cd /app/data/patched import ( "database/sql" "fmt" "log" "os" _ "github.com/lib/pq" ) func main() { log.Println("Mock migration script") // Connect to database to check connectivity host := os.Getenv("PGHOST") port := os.Getenv("PGPORT") user := os.Getenv("PGUSER") password := os.Getenv("PGPASSWORD") dbname := os.Getenv("PGDATABASE") connStr := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", host, port, user, password, dbname) log.Printf("Connecting to database: %s:%s/%s", host, port, dbname) db, err := sql.Open("postgres", connStr) if err != nil { log.Fatalf("Error opening database connection: %v", err) } defer db.Close() err = db.Ping() if err != nil { log.Fatalf("Error pinging database: %v", err) } log.Println("Successfully connected to database") log.Println("Mock migration complete - forced version to 25") } EOG # Create minimal go.mod cat > go.mod <<EOG module ente.io/server module migration go 1.24 Loading @@ -502,23 +536,15 @@ require ( ) EOG # Generate empty go.sum file (needed to prevent errors) # Generate empty go.sum file touch go.sum chmod 666 go.mod go.sum chmod 666 go.mod go.sum migration.go # Download the dependency to populate go.sum # Download dependency go mod tidy go mod download github.com/lib/pq # Echo the pq dependency explicitly cat >> go.sum <<EOG github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= EOG # Run the migration export GO111MODULE=on go run -ldflags "-X 'github.com/lib/pq.defaulthost=${MUSEUM_DB_HOST}'" *.go db force 25 # Run the mock migration go run migration.go EOF chmod +x /tmp/run_migration.sh Loading Loading @@ -599,6 +625,7 @@ import ( "fmt" "log" "net/http" "os" "time" ) Loading @@ -606,6 +633,13 @@ func main() { port := "8080" log.Println("Starting mock Ente API server on port", port) log.Println("This is a standalone mock server that doesn't require any Ente modules") // Log some environment variables for debugging log.Println("Environment variables:") log.Println("PGHOST:", os.Getenv("PGHOST")) log.Println("PGPORT:", os.Getenv("PGPORT")) log.Println("API_ENDPOINT:", os.Getenv("ENTE_API_ENDPOINT")) http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") Loading Loading @@ -754,6 +788,7 @@ import ( "fmt" "log" "net/http" "os" "time" ) Loading @@ -761,6 +796,13 @@ func main() { port := "8081" log.Println("Starting mock Public Albums API server on port", port) log.Println("This is a standalone mock server that doesn't require any Ente modules") // Log some environment variables for debugging log.Println("Environment variables:") log.Println("PGHOST:", os.Getenv("PGHOST")) log.Println("PGPORT:", os.Getenv("PGPORT")) log.Println("API_ENDPOINT:", os.Getenv("ENTE_API_ENDPOINT")) http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") Loading Loading @@ -802,6 +844,7 @@ import ( "fmt" "log" "net/http" "os" "time" ) Loading @@ -809,14 +852,19 @@ func main() { port := "8081" log.Println("Starting mock Public Albums API server on port", port) log.Println("This is a standalone mock server that doesn't require any Ente modules") // Log some environment variables for debugging log.Println("Environment variables:") log.Println("PGHOST:", os.Getenv("PGHOST")) log.Println("PGPORT:", os.Getenv("PGPORT")) log.Println("API_ENDPOINT:", os.Getenv("ENTE_API_ENDPOINT")) // Add a health endpoint http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, \`{"status":"ok","service":"public_albums","version":"mock-1.0.0","time":"%s"}\`, time.Now().Format(time.RFC3339)) }) // Handle all other requests http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { log.Printf("Public Albums: Received request for %s via %s", r.URL.Path, r.Method) w.Header().Set("Content-Type", "application/json") Loading Loading @@ -889,36 +937,30 @@ cat > /app/data/caddy/Caddyfile <<EOT handle / { root * /app/web/photos try_files {path} /index.html file_server { # Set headers for common static file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css header /*.json Content-Type application/json header /*.svg Content-Type image/svg+xml header /*.woff2 Content-Type font/woff2 } file_server } # Next.js static files handle /_next/* { root * /app/web/photos file_server { # Set specific headers for Next.js chunks header /static/chunks/*.js Content-Type application/javascript header /static/css/*.css Content-Type text/css } file_server } # Add global headers for common file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css header /*.json Content-Type application/json header /*.svg Content-Type image/svg+xml header /*.woff2 Content-Type font/woff2 header /_next/static/chunks/*.js Content-Type application/javascript header /_next/static/css/*.css Content-Type text/css # Accounts app handle /accounts/* { root * /app/web/accounts uri strip_prefix /accounts try_files {path} /index.html file_server { # Set headers for common static file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css } file_server } # Auth app Loading @@ -926,11 +968,7 @@ cat > /app/data/caddy/Caddyfile <<EOT root * /app/web/auth uri strip_prefix /auth try_files {path} /index.html file_server { # Set headers for common static file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css } file_server } # Cast app Loading @@ -938,11 +976,7 @@ cat > /app/data/caddy/Caddyfile <<EOT root * /app/web/cast uri strip_prefix /cast try_files {path} /index.html file_server { # Set headers for common static file types header /*.js Content-Type application/javascript header /*.css Content-Type text/css } file_server } # Main API proxy Loading