akiko19191 commited on
Commit
d8913ed
·
verified ·
1 Parent(s): 1afc99f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. 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
- # Set environment variables
5
- ENV HOST=0.0.0.0
6
- ENV PORT=7860
7
- ENV SESSION_EXPIRY=900000
8
- ENV REFRESH_TOKEN_EXPIRY=604800000
9
- # ENV MEILI_NO_ANALYTICS=true
10
- # ENV MEILI_HOST=https://librechat-meilisearch.hf.space
11
-
12
- # Create necessary directories
13
- RUN mkdir -p /app/uploads/temp
14
- RUN mkdir -p /app/client/public/images/temp
15
- RUN mkdir -p /app/api/logs/
16
- RUN mkdir -p /app/data
17
- RUN mkdir -p /app/code_interpreter
18
-
19
- # Give write permission to the directory
20
- RUN chmod -R 777 /app/uploads/temp
21
- RUN chmod -R 777 /app/client/public/images
22
- RUN chmod -R 777 /app/api/logs/
23
- RUN chmod -R 777 /app/data
24
- RUN chmod -R 777 /app/code_interpreter
25
-
26
- # RUN cd /app/packages/mcp/src/ && rm -rf manager.ts
27
-
28
- # Copy Custom Endpoints Config
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
- # Install dependencies
34
- RUN cd /app/api && npm install
35
  USER root
36
- # COPY manager.ts /app/packages/mcp/src/manager.ts
37
-
38
- # Install Python and pip
39
- ENV PYTHONUNBUFFERED=1
40
- RUN apk add --update --no-cache python3-dev git py3-pip gcc libc-dev bash libc6-compat build-base mpc1-dev && ln -sf python3 /usr/bin/python
41
- # RUN apk --update --no-cache add python3~3.10 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
42
- # RUN apk add --update --no-cache git gcc libc-dev libc6-compat build-base mpc1-dev && ln -sf python3 /usr/bin/python
43
-
44
- RUN pip3 install --no-cache --upgrade --break-system-packages pip pexpect setuptools mcp mcp-simple-pubmed mcp-simple-arxiv litellm gradio XlsxWriter openpyxl google-genai
45
- # RUN cd /app/packages && git clone --branch patch-1 https://github.com/vaibhavard/actors-mcp-server
46
- # RUN cd /app/packages/actors-mcp-server/ && npm install && npm run build && npm link
47
- # RUN git clone https://github.com/e2b-dev/mcp-server && cd mcp-server/packages/js/ && npm install && npm run build && npm link
48
- # to run on container star
49
- #RUN git clone https://github.com/AIGENHACKER/mcp-hfspace && cd mcp-hfspace && npm install && npm run build && npm link
50
- #RUN git clone https://github.com/exa-labs/exa-mcp-server && cd exa-mcp-server && npm install --save axios dotenv && npm run build && npm link
51
- RUN wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz -O ngrok.tgz && tar xvzf ngrok.tgz && cp ngrok /usr/local/bin && rm ngrok.tgz
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  USER node
53
- RUN ngrok config add-authtoken 2vPTfcN3MOK2T12aE2fxtBzjxue_6ejqTQUkkWqZfRm2QAN49
 
 
 
 
 
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"]