MahaNeta / Dockerfile
ankush-003's picture
Update Dockerfile
4079cf5 verified
FROM python:3.11-slim
# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment and set ownership
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV && \
chown -R user:user $VIRTUAL_ENV
# Switch to the "user" user
USER user
# Set home and PATH
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$VIRTUAL_ENV/bin:$PATH
# Set the working directory to the user's home directory
WORKDIR $HOME/app
# Copy requirements first (with correct ownership)
COPY --chown=user requirements.txt $HOME/app/requirements.txt
# Install dependencies in virtual environment
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt && \
pip install -qU chainlit
# Copy the rest of the application with correct ownership
COPY --chown=user . $HOME/app
# Create content directory for assets
RUN mkdir -p content
# Expose the default Chainlit port
EXPOSE 7860
# Command to run the application
CMD ["chainlit", "run", "app.py", "--port", "7860", "--host", "0.0.0.0"]