Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +90 -48
Dockerfile
CHANGED
@@ -1,55 +1,97 @@
|
|
1 |
-
#Pull the base image
|
2 |
FROM vaibhavarduino/librechat:latest
|
3 |
-
#FROM librechat/librechat-dev:latest
|
4 |
-
|
5 |
-
|
6 |
-
ENV
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
#
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
RUN mkdir -p /app/
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
# RUN curl -o /app/librechat.yaml https://raw.githubusercontent.com/LibreChat-AI/librechat-config-yaml/main/librechat-hf.yaml
|
30 |
-
COPY librechat.yaml /app/librechat.yaml
|
31 |
COPY tests.py /app/tests.py
|
32 |
|
33 |
-
#
|
34 |
-
|
35 |
USER root
|
36 |
-
|
37 |
-
|
38 |
-
#
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
#
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
#
|
47 |
-
#
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
USER node
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
USER root
|
|
|
55 |
CMD ["npm", "run", "backend"]
|
|
|
1 |
+
# Pull the base image
|
2 |
FROM vaibhavarduino/librechat:latest
|
3 |
+
# FROM librechat/librechat-dev:latest
|
4 |
+
|
5 |
+
# Set environment variables (Consider moving sensitive ones like ngrok token to build args or runtime envs)
|
6 |
+
ENV HOST=0.0.0.0 \
|
7 |
+
PORT=7860 \
|
8 |
+
SESSION_EXPIRY=900000 \
|
9 |
+
REFRESH_TOKEN_EXPIRY=604800000 \
|
10 |
+
# MEILI_NO_ANALYTICS=true \
|
11 |
+
# MEILI_HOST=https://librechat-meilisearch.hf.space \
|
12 |
+
PYTHONUNBUFFERED=1 \
|
13 |
+
NGROK_AUTHTOKEN=2vPTfcN3MOK2T12aE2fxtBzjxue_6ejqTQUkkWqZfRm2QAN49 # Added here for ngrok setup
|
14 |
+
|
15 |
+
# Combine directory creation and permission setting
|
16 |
+
RUN mkdir -p /app/uploads/temp \
|
17 |
+
/app/client/public/images/temp \
|
18 |
+
/app/api/logs/ \
|
19 |
+
/app/data \
|
20 |
+
/app/code_interpreter && \
|
21 |
+
chmod -R 777 /app/uploads/temp \
|
22 |
+
/app/client/public/images \
|
23 |
+
/app/api/logs/ \
|
24 |
+
/app/data \
|
25 |
+
/app/code_interpreter
|
26 |
+
|
27 |
+
# Copy configuration and tests
|
28 |
+
COPY librechat.yaml /app/librechat.yaml
|
|
|
|
|
29 |
COPY tests.py /app/tests.py
|
30 |
|
31 |
+
# --- Build Stage ---
|
32 |
+
# Temporarily switch to root for package installation
|
33 |
USER root
|
34 |
+
|
35 |
+
# Install Node.js dependencies first (leverages layer cache if package.json doesn't change often)
|
36 |
+
# Assuming package.json is in /app/api in the base image or copied before
|
37 |
+
# If not, uncomment and adjust COPY commands if needed:
|
38 |
+
# COPY api/package.json api/package-lock.json* ./api/
|
39 |
+
RUN cd /app/api && npm install --omit=dev --no-audit --no-fund --prefer-offline && npm cache clean --force
|
40 |
+
# Note: Using --omit=dev might break if runtime needs dev deps. Remove if necessary.
|
41 |
+
# --prefer-offline might help if network is slow/flaky, uses cache more aggressively.
|
42 |
+
# npm cache clean --force might free up a little space within the layer.
|
43 |
+
|
44 |
+
# Install system dependencies (including build tools), Python packages, and cleanup in one RUN command
|
45 |
+
# Reduces layers and removes build tools afterwards
|
46 |
+
RUN apk add --no-cache --virtual .build-deps \
|
47 |
+
build-base \
|
48 |
+
gcc \
|
49 |
+
libc-dev \
|
50 |
+
mpc1-dev \
|
51 |
+
python3-dev && \
|
52 |
+
apk add --no-cache \
|
53 |
+
bash \
|
54 |
+
git \
|
55 |
+
libc6-compat \
|
56 |
+
py3-pip \
|
57 |
+
python3 && \
|
58 |
+
ln -sf python3 /usr/bin/python && \
|
59 |
+
# Consider specific versions if needed: python3~=3.10
|
60 |
+
echo "Starting pip install..." && \
|
61 |
+
pip3 install --no-cache-dir --upgrade --break-system-packages \
|
62 |
+
pip \
|
63 |
+
setuptools \
|
64 |
+
mcp \
|
65 |
+
mcp-simple-pubmed \
|
66 |
+
mcp-simple-arxiv \
|
67 |
+
litellm \
|
68 |
+
gradio \
|
69 |
+
XlsxWriter \
|
70 |
+
openpyxl \
|
71 |
+
google-genai \
|
72 |
+
pexpect && \
|
73 |
+
# (Add back commented packages here if needed, e.g., actors-mcp-server)
|
74 |
+
echo "Pip install finished. Cleaning up..." && \
|
75 |
+
# Install ngrok
|
76 |
+
wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz -O ngrok.tgz && \
|
77 |
+
tar xvzf ngrok.tgz -C /usr/local/bin --strip-components=1 ngrok && \
|
78 |
+
rm ngrok.tgz && \
|
79 |
+
# Configure ngrok (token ideally passed at runtime or via build arg)
|
80 |
+
ngrok config add-authtoken $NGROK_AUTHTOKEN && \
|
81 |
+
# Clean up build dependencies and apk cache
|
82 |
+
apk del .build-deps && \
|
83 |
+
rm -rf /var/cache/apk/* /root/.cache /tmp/* && \
|
84 |
+
echo "Cleanup finished."
|
85 |
+
|
86 |
+
# Switch back to the non-root user defined in the base image (assuming 'node')
|
87 |
+
# Check the base image documentation if unsure about the default user
|
88 |
USER node
|
89 |
+
|
90 |
+
# Set the working directory (good practice)
|
91 |
+
WORKDIR /app
|
92 |
+
|
93 |
+
# Expose the port the app runs on
|
94 |
+
EXPOSE 7860
|
95 |
USER root
|
96 |
+
# Define the command to run the application
|
97 |
CMD ["npm", "run", "backend"]
|