File size: 1,773 Bytes
79becd2
 
d52c192
79becd2
d52c192
45041ff
c7401ed
e9bdc69
d52c192
ff5ba96
f7ed979
e9bdc69
f002194
 
d52c192
 
 
 
 
 
 
 
 
 
f7ed979
d52c192
b318189
 
 
 
65634c0
 
 
d52c192
41fa590
 
 
 
 
 
d52c192
4c667a3
 
d52c192
c203e6d
 
 
 
 
 
d52c192
 
 
 
45041ff
d52c192
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
57
#!/bin/sh

echo "Using remote PostgreSQL on Neon.tech..."

# Skip local PostgreSQL init and start

# 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

# Set Neon PostgreSQL connection environment variables
export PGHOST='ep-steep-dream-adqtvjel-pooler.c-2.us-east-1.aws.neon.tech'
export PGDATABASE='neondb'
export PGUSER='neondb_owner'
export PGPASSWORD='npg_Qq0B1uWRXavx'
export PGSSLMODE='require'
export PGCHANNELBINDING='require'

# Compose the DATABASE_URL
export DATABASE_URL="postgresql://${PGUSER}:${PGPASSWORD}@${PGHOST}:5432/${PGDATABASE}?sslmode=${PGSSLMODE}&channel_binding=${PGCHANNELBINDING}"

# Export 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
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
export AUTH_DISABLE_USERNAME_PASSWORD="true"

# Handle signup disabling logic
if [ -n "$AUTH_DISABLE_SIGNUP" ]; then
    export AUTH_DISABLE_SIGNUP="$AUTH_DISABLE_SIGNUP"
else
    export AUTH_DISABLE_SIGNUP="false"
fi

# Log connection details (don't do this in production with real passwords!)
echo "Connecting to Neon PostgreSQL at $PGHOST"

# Start Next.js app
echo "Starting Next.js..."
./web/entrypoint.sh node ./web/server.js