Commit f9c17035 authored by Andreas Düren's avatar Andreas Düren
Browse files

Fix user creation issues and add debugging

parent 3558003b
Loading
Loading
Loading
Loading
+56 −5
Original line number Diff line number Diff line
@@ -85,10 +85,24 @@ EOT
    echo "    3. Rename the file to s3.env"
    echo "    4. Restart the app"
    
    # Exit with a message if this is the first run
    # For initial setup, create a placeholder S3 config to allow user creation
    # This will let the app start and allow initial setup
    if [[ ! -f /app/data/config/s3.env ]]; then
        echo "==> Exiting. Please configure S3 storage and restart the app."
        exit 1
        echo "==> Creating temporary S3 configuration to allow initial setup"
        cat > /app/data/config/s3.env <<EOT
# Temporary S3 configuration - please replace with real values
S3_ENDPOINT=http://localhost:9000
S3_REGION=us-east-1
S3_BUCKET=ente-test
S3_ACCESS_KEY=minioadmin
S3_SECRET_KEY=minioadmin
S3_PREFIX=ente/
EOT
        echo "==> Temporary S3 configuration created to allow initial user creation"
        echo "==> Please replace with real S3 credentials after first user is created"
        
        # Modify config to make S3 optional during initial setup
        sed -i 's/storage.type: "s3"/storage.type: "local"/' /app/data/config/config.yaml
    fi
fi

@@ -103,6 +117,13 @@ fi
# Load S3 environment variables
source /app/data/config/s3.env

# Print S3 configuration (without sensitive values)
echo "==> S3 Configuration:"
echo "    Endpoint: ${S3_ENDPOINT}"
echo "    Region: ${S3_REGION}"
echo "    Bucket: ${S3_BUCKET}"
echo "    Prefix: ${S3_PREFIX:-ente/}"

# Update the config file with S3 credentials
sed -i \
    -e "s|%%S3_ENDPOINT%%|${S3_ENDPOINT}|g" \
@@ -183,6 +204,8 @@ http {
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host \$host;
            proxy_cache_bypass \$http_upgrade;
            access_log /dev/stdout;
            error_log /dev/stderr debug;
        }
    }
}
@@ -284,6 +307,16 @@ cd "$SERVER_DIR"
# Set Go module cache to a writable location
export GOPATH=/app/data/go
export GO111MODULE=on
# Prevent Go from trying to download newer versions
export GOTOOLCHAIN=local
export GOPROXY=direct

# Set up more verbose logging for API debugging
export ENTE_LOG_LEVEL=debug

# Test if API endpoint is reachable
echo "==> Testing API connectivity"
curl -v http://localhost:8000/api/health || echo "API not yet available, this is normal during startup"

# Set up database environment variables
export ENTE_DB_USER="${CLOUDRON_POSTGRESQL_USERNAME}"
@@ -307,18 +340,36 @@ chown -R cloudron:cloudron /app/data
# Start Museum server on port 8000 (different from the NGINX port 8080)
echo "==> Starting Museum server"

# Modify environment variables for frontend
echo "==> Setting up environment variables for frontend"
# For web frontend, these aren't changing
export NEXT_PUBLIC_ENTE_ENDPOINT="${CLOUDRON_APP_ORIGIN}"

# First check for pre-built Museum binary
if find "$SERVER_DIR" -name "museum" -type f -executable | grep -q .; then
    MUSEUM_BIN=$(find "$SERVER_DIR" -name "museum" -type f -executable | head -1)
    echo "==> Found Museum binary at $MUSEUM_BIN"
    /usr/local/bin/gosu cloudron:cloudron "$MUSEUM_BIN" --port 8000 &
    /usr/local/bin/gosu cloudron:cloudron "$MUSEUM_BIN" --port 8000 \
        --storage.s3.endpoint="${S3_ENDPOINT}" \
        --storage.s3.region="${S3_REGION}" \
        --storage.s3.bucket="${S3_BUCKET}" \
        --storage.s3.accessKey="${S3_ACCESS_KEY}" \
        --storage.s3.secretKey="${S3_SECRET_KEY}" \
        --storage.s3.prefix="${S3_PREFIX:-ente/}" &
    SERVER_PID=$!
    echo "==> Museum server started with PID $SERVER_PID"
# Next check for cmd/museum directory pattern
elif [ -d "$SERVER_DIR/cmd/museum" ]; then
    echo "==> Found Museum source in cmd/museum, running with go run"
    cd "$SERVER_DIR"
    /usr/local/bin/gosu cloudron:cloudron go run cmd/museum/main.go --port 8000 &
    /usr/local/bin/gosu cloudron:cloudron go run cmd/museum/main.go --port 8000 \
        --storage.s3.endpoint="${S3_ENDPOINT}" \
        --storage.s3.region="${S3_REGION}" \
        --storage.s3.bucket="${S3_BUCKET}" \
        --storage.s3.accessKey="${S3_ACCESS_KEY}" \
        --storage.s3.secretKey="${S3_SECRET_KEY}" \
        --storage.s3.prefix="${S3_PREFIX:-ente/}" \
        --log.level=debug &
    SERVER_PID=$!
    echo "==> Museum server started with PID $SERVER_PID"
# Next try to find any main.go for the Museum