Spaces:
Running
Running
Commit
·
e3aa5a6
verified
·
0
Parent(s):
Duplicate from langfuse/langfuse-template-space
Browse files- .gitattributes +35 -0
- Dockerfile +19 -0
- README.md +19 -0
- docker-entrypoint-wrapper.sh +81 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM langfuse/langfuse:2
|
2 |
+
|
3 |
+
USER root
|
4 |
+
|
5 |
+
# Install PostgreSQL and necessary dependencies
|
6 |
+
RUN apk update && apk add --no-cache \
|
7 |
+
postgresql \
|
8 |
+
postgresql-contrib \
|
9 |
+
net-tools \
|
10 |
+
iproute2 \
|
11 |
+
sed
|
12 |
+
|
13 |
+
# Copy and set up the wrapper script
|
14 |
+
COPY docker-entrypoint-wrapper.sh /docker-entrypoint-wrapper.sh
|
15 |
+
RUN chmod +x /docker-entrypoint-wrapper.sh
|
16 |
+
|
17 |
+
EXPOSE 3000
|
18 |
+
|
19 |
+
ENTRYPOINT ["dumb-init", "--", "/docker-entrypoint-wrapper.sh"]
|
README.md
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Langfuse Template Space
|
3 |
+
emoji: 🪢
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: indigo
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
app_port: 3000
|
9 |
+
hf_oauth: true
|
10 |
+
hf_oauth_expiration_minutes: 480
|
11 |
+
hf_oauth_scopes:
|
12 |
+
- email
|
13 |
+
custom_headers:
|
14 |
+
cross-origin-resource-policy: cross-origin
|
15 |
+
cross-origin-opener-policy: same-origin
|
16 |
+
suggested_storage: small
|
17 |
+
---
|
18 |
+
|
19 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
docker-entrypoint-wrapper.sh
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/sh
|
2 |
+
|
3 |
+
# Create necessary directories in the persistent /data volume
|
4 |
+
echo "Creating necessary directories in the persistent /data volume..."
|
5 |
+
mkdir -p /data/postgresql/data /data/postgresql/run
|
6 |
+
chmod 0700 /data/postgresql/data
|
7 |
+
chmod 0755 /data/postgresql/run
|
8 |
+
|
9 |
+
# Initialize PostgreSQL if not already initialized
|
10 |
+
echo "Initializing PostgreSQL if not already initialized..."
|
11 |
+
if [ ! -f "/data/postgresql/data/PG_VERSION" ]; then
|
12 |
+
# Initialize database
|
13 |
+
echo "Initializing database..."
|
14 |
+
initdb -D /data/postgresql/data
|
15 |
+
|
16 |
+
# Modify pg_hba.conf to allow local connections
|
17 |
+
echo "local all all trust" > /data/postgresql/data/pg_hba.conf
|
18 |
+
echo "host all all 127.0.0.1/32 trust" >> /data/postgresql/data/pg_hba.conf
|
19 |
+
echo "host all all ::1/128 trust" >> /data/postgresql/data/pg_hba.conf
|
20 |
+
echo "host all all 0.0.0.0/0 trust" >> /data/postgresql/data/pg_hba.conf
|
21 |
+
echo "host all all ::/0 trust" >> /data/postgresql/data/pg_hba.conf
|
22 |
+
fi
|
23 |
+
|
24 |
+
# Start PostgreSQL with the persistent directories
|
25 |
+
echo "Starting PostgreSQL..."
|
26 |
+
pg_ctl -D /data/postgresql/data -o "-c listen_addresses='*' -c unix_socket_directories='/data/postgresql/run'" start
|
27 |
+
|
28 |
+
# Wait for PostgreSQL to be ready
|
29 |
+
echo "Waiting for PostgreSQL to be ready..."
|
30 |
+
until pg_isready -h localhost; do
|
31 |
+
echo "Waiting for PostgreSQL to be ready..."
|
32 |
+
sleep 1
|
33 |
+
done
|
34 |
+
|
35 |
+
# Create database and roles
|
36 |
+
echo "Creating database and roles..."
|
37 |
+
createuser -h /data/postgresql/run -s postgres || true
|
38 |
+
createdb -h /data/postgresql/run node || true
|
39 |
+
|
40 |
+
# Set NEXTAUTH_URL based on SPACE_HOST if available
|
41 |
+
if [ -n "$SPACE_ID" ]; then
|
42 |
+
echo "Setting NEXTAUTH_URL to https://huggingface.co/spaces/${SPACE_ID}"
|
43 |
+
# export NEXTAUTH_URL="https://huggingface.co/spaces/${SPACE_ID}"
|
44 |
+
export NEXTAUTH_URL="https://${SPACE_HOST}"
|
45 |
+
else
|
46 |
+
echo "WARNING: SPACE_ID not found"
|
47 |
+
fi
|
48 |
+
|
49 |
+
# Update DATABASE_URL to use TCP connection
|
50 |
+
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/node"
|
51 |
+
|
52 |
+
# Export these environment variables to influence Next.js binding
|
53 |
+
export HOSTNAME="0.0.0.0"
|
54 |
+
export HOST="0.0.0.0"
|
55 |
+
export PORT=3000
|
56 |
+
|
57 |
+
# Disable CSP headers to allow for embedded use within HF
|
58 |
+
export LANGFUSE_CSP_DISABLE="true"
|
59 |
+
|
60 |
+
# Preset oauth env vars based on injected space variables
|
61 |
+
# See https://huggingface.co/docs/hub/en/spaces-oauth#create-an-oauth-app
|
62 |
+
export AUTH_CUSTOM_CLIENT_ID=$OAUTH_CLIENT_ID
|
63 |
+
export AUTH_CUSTOM_CLIENT_SECRET=$OAUTH_CLIENT_SECRET
|
64 |
+
export AUTH_CUSTOM_ISSUER=$OPENID_PROVIDER_URL
|
65 |
+
export AUTH_CUSTOM_SCOPE=$OAUTH_SCOPES
|
66 |
+
export AUTH_CUSTOM_NAME="Hugging Face"
|
67 |
+
|
68 |
+
# Disable authentication via username/password to enforce authentication via HF
|
69 |
+
export AUTH_DISABLE_USERNAME_PASSWORD="true"
|
70 |
+
|
71 |
+
# Pass through AUTH_DISABLE_SIGNUP value if set, default to false if not set
|
72 |
+
if [ -n "$AUTH_DISABLE_SIGNUP" ]; then
|
73 |
+
export AUTH_DISABLE_SIGNUP="$AUTH_DISABLE_SIGNUP"
|
74 |
+
else
|
75 |
+
export AUTH_DISABLE_SIGNUP="false"
|
76 |
+
fi
|
77 |
+
|
78 |
+
# Start Next.js in the background
|
79 |
+
echo "Starting Next.js..."
|
80 |
+
./web/entrypoint.sh node ./web/server.js \
|
81 |
+
--keepAliveTimeout 110000
|