flask-rtod / Dockerfile
kurnie's picture
Update Dockerfile
d7cc54c verified
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile
FROM python:3.9
RUN useradd -m -u 1000 user
USER root
ENV PATH="/home/user/.local/bin:$PATH"
ENV TORCH_HOME=/app/torch_cache
WORKDIR /app
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
RUN apt-get update && apt-get install libgl1 -y
RUN mkdir -p /app/torch_cache && chown -R user:user /app/torch_cache && chmod -R 755 /app/torch_cache
RUN mkdir -p /app/torch_cache/hub && chown -R user:user /app/torch_cache/hub && chmod -R 755 /app/torch_cache/hub
RUN mkdir -p /app/data && chown -R user:user /app/data && chmod -R 755 /app/data
RUN mkdir -p /app/torch_cache/hub/ultralytics-yolov5-d611217/ && chown -R user:user /app/torch_cache/hub/ultralytics-yolov5-d611217/ && chmod -R 755 /app/torch_cache/hub/ultralytics-yolov5-d611217/
COPY --chown=user ./yolov5/weights/model5.pt /app/models/model5.pt
COPY --chown=user . /app
RUN chown -R user:user /app && chmod -R 755 /app
CMD ["gunicorn", "-w", "4", "app:app", "-b", "0.0.0.0:7860"]