Librechat-copy / Dockerfile
akiko19191's picture
Update Dockerfile
80fb6e4 verified
# Pull the base image
FROM vaibhavarduino/librechat:latest
# FROM librechat/librechat-dev:latest
# Set environment variables (Consider moving sensitive ones like ngrok token to build args or runtime envs)
ENV HOST=0.0.0.0 \
PORT=7860 \
SESSION_EXPIRY=900000 \
REFRESH_TOKEN_EXPIRY=604800000 \
# MEILI_NO_ANALYTICS=true \
# MEILI_HOST=https://librechat-meilisearch.hf.space \
PYTHONUNBUFFERED=1 \
NGROK_AUTHTOKEN=2vPTfcN3MOK2T12aE2fxtBzjxue_6ejqTQUkkWqZfRm2QAN49
# Combine directory creation and permission setting
RUN mkdir -p /app/uploads/temp \
/app/client/public/images/temp \
/app/api/logs/ \
/app/data \
/app/code_interpreter && \
chmod -R 777 /app/uploads/temp \
/app/client/public/images \
/app/api/logs/ \
/app/data \
/app/code_interpreter
# Copy configuration and tests
COPY librechat.yaml /app/librechat.yaml
COPY tests.py /app/tests.py
# --- Build Stage ---
# Temporarily switch to root for package installation
USER root
RUN sed -i 's/#\(.*\/community\)/\1/' /etc/apk/repositories
# Install Node.js dependencies first (leverages layer cache if package.json doesn't change often)
# Assuming package.json is in /app/api in the base image or copied before
# If not, uncomment and adjust COPY commands if needed:
# COPY api/package.json api/package-lock.json* ./api/
RUN cd /app/api && npm install --omit=dev --no-audit --no-fund --prefer-offline && npm cache clean --force
# Note: Using --omit=dev might break if runtime needs dev deps. Remove if necessary.
# --prefer-offline might help if network is slow/flaky, uses cache more aggressively.
# npm cache clean --force might free up a little space within the layer.
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
# Install system dependencies (including build tools), Python packages, and cleanup in one RUN command
# Reduces layers and removes build tools afterwards
RUN apk add --no-cache --virtual .build-deps \
build-base \
gcc \
libc-dev \
mpc1-dev \
python3-dev && \
apk add --no-cache \
bash \
git \
expect \
busybox-suid \
libc6-compat \
py3-pip \
openjdk21 \
zlib-dev \
python3 && \
ln -sf python3 /usr/bin/python && \
# Consider specific versions if needed: python3~=3.10
echo "Starting pip install..." && \
pip3 install --no-cache-dir --upgrade --break-system-packages \
pip \
setuptools \
mcp \
mcp-simple-pubmed \
mcp-simple-arxiv \
mpxj \
jpype1 \
litellm==1.67.2 \
gradio \
XlsxWriter \
openpyxl \
google-genai \
matplotlib \
requests-futures \
pexpect && \
# (Add back commented packages here if needed, e.g., actors-mcp-server)
echo "Pip install finished. Cleaning up..." && \
apk del .build-deps && \
rm -rf /var/cache/apk/* /root/.cache /tmp/* && \
echo "Cleanup finished."
# RUN su root
USER root
WORKDIR /app
RUN git clone https://github.com/AIGENHACKER/mcp-hfspace && cd mcp-hfspace && npm install && npm run build && npm link
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
EXPOSE 7860
USER root
RUN npm install -g express ejs chart.js && npm cache clean --force
USER node
RUN ngrok config add-authtoken 2vPTfcN3MOK2T12aE2fxtBzjxue_6ejqTQUkkWqZfRm2QAN49
USER root
CMD ["npm", "run", "backend"]