not-gemini / Dockerfile
likhonsheikhdev's picture
Update Dockerfile
1687e0a verified
# 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" ]