Spaces:
Configuration error
Configuration error
Commit
·
5577464
1
Parent(s):
7d21a9e
initial commit
Browse files- Dockerfile +26 -0
- README.md +5 -9
- custom_startup.sh +42 -0
Dockerfile
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM ghcr.io/huggingface/chat-ui-db:0.9.4
|
2 |
+
|
3 |
+
# Switch to root to perform necessary setup steps like copying the startup script
|
4 |
+
USER root
|
5 |
+
|
6 |
+
# REMOVE THESE LINES from Dockerfile. They will be in custom_startup.sh now:
|
7 |
+
# RUN mkdir -p /data/db
|
8 |
+
# RUN chown -R 1000:1000 /data/db
|
9 |
+
|
10 |
+
# Copy and make executable your custom startup script (MUST be done as root)
|
11 |
+
COPY custom_startup.sh /usr/local/bin/custom_startup.sh
|
12 |
+
RUN chmod +x /usr/local/bin/custom_startup.sh
|
13 |
+
|
14 |
+
# Switch back to the 'user' for application execution
|
15 |
+
USER user
|
16 |
+
|
17 |
+
# Set the working directory (assuming /app is where ChatUI expects files)
|
18 |
+
WORKDIR /app
|
19 |
+
|
20 |
+
# (Keep or remove these COPY lines based on whether you're bringing your own files)
|
21 |
+
# COPY package.json ./package.json
|
22 |
+
# COPY .env.local ./
|
23 |
+
# COPY build/ ./build/
|
24 |
+
# COPY .env ./
|
25 |
+
|
26 |
+
CMD ["/usr/local/bin/custom_startup.sh"]
|
README.md
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
colorFrom: green
|
5 |
-
colorTo: yellow
|
6 |
sdk: docker
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
emoji: 🤖🔥
|
2 |
+
colorFrom: gray
|
3 |
+
colorTo: gray
|
|
|
|
|
4 |
sdk: docker
|
5 |
+
app_port: 3000
|
6 |
+
pinned: false
|
|
|
|
custom_startup.sh
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# --- 1. Handle .env.local ---
|
4 |
+
ENV_LOCAL_PATH=/app/.env.local
|
5 |
+
if test -z "${DOTENV_LOCAL}" ; then
|
6 |
+
if ! test -f "${ENV_LOCAL_PATH}" ; then
|
7 |
+
echo "DOTENV_LOCAL was not found in the ENV variables and .env.local is not set using a bind volume. Make sure to set environment variables properly. "
|
8 |
+
fi;
|
9 |
+
else
|
10 |
+
echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file."
|
11 |
+
cat <<< "$DOTENV_LOCAL" > ${ENV_LOCAL_PATH}
|
12 |
+
fi;
|
13 |
+
|
14 |
+
# --- 2. Create MongoDB Data Directory ---
|
15 |
+
echo "Ensuring MongoDB data directory exists and has correct permissions ON PERSISTENT VOLUME..."
|
16 |
+
mkdir -p /data/db
|
17 |
+
chown -R user:user /data/db
|
18 |
+
echo "MongoDB data directory setup complete."
|
19 |
+
|
20 |
+
# --- 3. Create Models Directory (NEW FIX) ---
|
21 |
+
# This directory is expected by the app even when using remote endpoints.
|
22 |
+
echo "Ensuring models directory exists and has correct permissions ON PERSISTENT VOLUME..."
|
23 |
+
mkdir -p /data/models # <--- ADD THIS LINE
|
24 |
+
chown -R user:user /data/models # <--- ADD THIS LINE
|
25 |
+
echo "Models directory setup complete."
|
26 |
+
|
27 |
+
# --- 4. Start MongoDB ---
|
28 |
+
echo "Starting local MongoDB instance..."
|
29 |
+
nohup mongod &
|
30 |
+
echo "MongoDB started in background. Waiting a few seconds for it to initialize..."
|
31 |
+
sleep 5
|
32 |
+
|
33 |
+
# --- 5. Handle PUBLIC_VERSION (Patch for base image's bug) ---
|
34 |
+
echo "Setting PUBLIC_VERSION (patching base image's package.json lookup bug)..."
|
35 |
+
if [ -z "$PUBLIC_VERSION" ]; then
|
36 |
+
export PUBLIC_VERSION="0.0.1"
|
37 |
+
fi
|
38 |
+
echo "PUBLIC_VERSION set to: $PUBLIC_VERSION"
|
39 |
+
|
40 |
+
# --- 6. Start ChatUI Application ---
|
41 |
+
echo "Starting ChatUI application..."
|
42 |
+
exec dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000
|