Spaces:
Runtime error
Runtime error
File size: 2,599 Bytes
1687e0a 3c05e28 1687e0a 3c05e28 1687e0a 3c05e28 1687e0a 3c05e28 1687e0a 06f7327 1687e0a 06f7327 1687e0a 06f7327 1687e0a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# Base image for chat-ui
FROM ghcr.io/huggingface/chat-ui:latest AS base
# Final image for text-generation-inference and chat-ui
FROM ghcr.io/huggingface/text-generation-inference:latest AS final
# --- Build Arguments ---
# MODEL_NAME: The Hugging Face model ID to load for text generation.
# Example: "codellama/CodeLlama-7b-Instruct-hf"
ARG MODEL_NAME
ENV MODEL_NAME=${MODEL_NAME}
# --- Environment Variables ---
# Set timezone and the default port for the chat UI
ENV TZ=Europe/Paris \
PORT=3000
# --- MongoDB Installation ---
# Add MongoDB repository GPG key
RUN curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
--dearmor
# Add MongoDB repository to sources list
RUN echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list
# Install MongoDB
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
mongodb-org && \
rm -rf /var/lib/apt/lists/*
# --- Node.js Installation ---
# Add NodeSource repository for Node.js 20.x
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | /bin/bash -
# Install Node.js
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
nodejs && \
rm -rf /var/lib/apt/lists/*
# --- Image Setup ---
# Create a non-root user for security
RUN useradd -m -u 1000 user
# Create directories for application and data, and set ownership
RUN mkdir /app
RUN chown -R 1000:1000 /app
RUN mkdir /data
RUN chown -R 1000:1000 /data
# Switch to the "user" user for subsequent operations
USER user
# Set HOME directory and update PATH for the user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Install dotenv-cli globally for the user
RUN npm config set prefix /home/user/.local
RUN npm install -g dotenv-cli
# --- Copy Chat-UI Assets from Base Image ---
COPY --from=base --chown=1000 /app/node_modules /app/node_modules
COPY --from=base --chown=1000 /app/package.json /app/package.json
COPY --from=base --chown=1000 /app/build /app/build
# Copy environment files
COPY --from=base --chown=1000 /app/.env /app/.env
COPY --chown=1000 .env.local /app/.env.local
# Copy the entrypoint script and make it executable
COPY --chown=1000 entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# --- Entrypoint ---
# The entrypoint script orchestrates the startup of MongoDB, TGI, and Chat-UI.
ENTRYPOINT [ "/app/entrypoint.sh" ] |