Spaces:
Paused
Paused
# Use Python base image | |
FROM python:3.9 | |
# Set environment variables | |
ENV DEBIAN_FRONTEND=noninteractive \ | |
PYTHONUNBUFFERED=1 \ | |
SHELL=/bin/bash \ | |
TZ=Europe/Paris | |
# Install some basic utilities | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
wget \ | |
curl \ | |
git \ | |
sudo \ | |
procps \ | |
git-lfs \ | |
zip \ | |
unzip \ | |
htop \ | |
vim \ | |
nano \ | |
bzip2 \ | |
build-essential \ | |
libsndfile-dev \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create the /app and /data directories and set permissions before switching to the non-root user | |
RUN mkdir -p /app /data && \ | |
chmod -R 777 /data && \ | |
adduser --disabled-password --gecos '' --shell /bin/bash user && \ | |
chown -R user:user /app | |
# Allow the user to run sudo commands without a password | |
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user | |
# Switch to the non-root user | |
USER user | |
# Set the user's home directory and configure permissions for home directories | |
ENV HOME=/home/user | |
RUN mkdir -p $HOME/.cache $HOME/.config && chmod -R 777 $HOME | |
# Set the working directory to /app | |
WORKDIR /app | |
# Copy requirements.txt and install dependencies as the non-root user | |
COPY --chown=user requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the start_server.sh script and make it executable | |
COPY --chown=user start_server.sh . | |
RUN chmod +x start_server.sh | |
# Expose the MLflow port | |
EXPOSE 7860 | |
# Start the MLflow server using the start_server.sh script | |
CMD ["./start_server.sh"] | |