autotrain-playground / Dockerfile
dsmueller's picture
Update Dockerfile to fix broken OpenCV installation
609bf51
# Use an official Python runtime as a parent image
FROM python:3.11.1
# Set up user
RUN useradd -m -u 1000 user
USER user
# Install Cargo (Rust's package manager), needed for hf_transfer
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
# Set up environment variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:/home/user/.cargo/bin:$PATH
# Set the working directory in the container
WORKDIR $HOME/app
# Copy the current directory contents into the container at /home/user/app
COPY --chown=user . $HOME/app
# Set user to root
USER root
# Install any needed packages specified in requirements.txt
RUN python -m venv /venv && \
/venv/bin/pip install --no-cache-dir -r requirements.txt
# Fix broken OpenCV installation for docker container
RUN apt-get update && apt-get install -y libgl1 && apt-get install -y python3-opencv
# RUN /venv/bin/pip install opencv-python
# Set user back to non-root
USER user
# Make port 80 available to the world outside this container
EXPOSE 80
# Generate requirements.txt using pip freeze
RUN /venv/bin/pip freeze > requirements.txt
# Run train_llm.py when the container launches
CMD ["/bin/bash", "-c", "source /venv/bin/activate && python train_llm.py"]