File size: 1,959 Bytes
3360f8c
79becd2
3360f8c
79becd2
3360f8c
 
 
 
 
 
f002194
 
3360f8c
 
f7ed979
3360f8c
b318189
 
 
 
3360f8c
a14766d
3360f8c
 
 
 
 
 
 
41fa590
3360f8c
 
4c667a3
 
3360f8c
 
 
 
 
 
a14766d
3360f8c
 
 
 
 
 
 
 
c203e6d
3360f8c
c203e6d
3360f8c
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh

echo "===== Application Startup at $(date) ====="

# Set NEXTAUTH_URL based on SPACE_HOST if available
if [ -n "$SPACE_ID" ]; then
    echo "Setting NEXTAUTH_URL to https://${SPACE_HOST}"
    export NEXTAUTH_URL="https://${SPACE_HOST}"
else
    echo "WARNING: SPACE_ID not found"
fi

# Use Neon PostgreSQL database (no local setup needed)
export DATABASE_URL="postgresql://neondb_owner:npg_Qq0B1uWRXavx@ep-steep-dream-adqtvjel-pooler.c-2.us-east-1.aws.neon.tech:5432/neondb?sslmode=require"

# Export these environment variables to influence Next.js binding
export HOSTNAME="0.0.0.0"
export HOST="0.0.0.0"
export PORT=3000

# Disable CSP headers to allow for embedded use within HF
export LANGFUSE_CSP_DISABLE="true"

# Preset oauth env vars based on injected space variables
# See https://huggingface.co/docs/hub/en/spaces-oauth#create-an-oauth-app
export AUTH_CUSTOM_CLIENT_ID=$OAUTH_CLIENT_ID
export AUTH_CUSTOM_CLIENT_SECRET=$OAUTH_CLIENT_SECRET
export AUTH_CUSTOM_ISSUER=$OPENID_PROVIDER_URL
export AUTH_CUSTOM_SCOPE=$OAUTH_SCOPES
export AUTH_CUSTOM_NAME="Hugging Face"

# Disable authentication via username/password to enforce authentication via HF
export AUTH_DISABLE_USERNAME_PASSWORD="true"

# Pass through AUTH_DISABLE_SIGNUP value if set, default to false if not set
if [ -n "$AUTH_DISABLE_SIGNUP" ]; then
    export AUTH_DISABLE_SIGNUP="$AUTH_DISABLE_SIGNUP"
else
    export AUTH_DISABLE_SIGNUP="false"
fi

# Test database connection
echo "Testing database connection..."
if command -v pg_isready > /dev/null 2>&1; then
    if pg_isready -h ep-steep-dream-adqtvjel-pooler.c-2.us-east-1.aws.neon.tech -p 5432; then
        echo "Database connection successful!"
    else
        echo "Database connection failed, but proceeding anyway..."
    fi
else
    echo "pg_isready not available, skipping connection test..."
fi

# Start Langfuse
echo "Starting Langfuse..."
exec ./web/entrypoint.sh node ./web/server.js --keepAliveTimeout 110000