Spaces:
Sleeping
Sleeping
File size: 1,405 Bytes
9e2f6a9 a07c712 0674d0d a0bcc0b 0674d0d a0bcc0b a07c712 fb820b1 1aa7e02 fb820b1 1aa7e02 7322ccd 1aa7e02 0674d0d a0bcc0b 0674d0d a0bcc0b 0674d0d a0bcc0b 979d308 0674d0d a0bcc0b 0674d0d c983c07 a07c712 9e2f6a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
FROM python:3.10.9
# Set working directory early for clean pathing
WORKDIR /code
# Copy requirements and install them as root (good practice)
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# Hugging Face ์บ์ ๋๋ ํ ๋ฆฌ ์ค์ ๋ฐ ์์ฑ (HF_HOME ๊ณ ๋ ค)
ENV TRANSFORMERS_CACHE=/tmp/huggingface_cache
ENV HF_HOME=/tmp/huggingface_home
RUN mkdir -p /tmp/huggingface_cache /tmp/huggingface_home
# Matplotlib ์บ์ ๋๋ ํ ๋ฆฌ ์ค์ ๋ฐ ์์ฑ
ENV MPLCONFIGDIR=/tmp/matplotlib_cache
RUN mkdir -p /tmp/matplotlib_cache
# OpenGL ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น (opencv-python ์ค์น ์ ์)
RUN apt-get update && apt-get install -y libgl1
# ์ฌ์ฉ์ ์์ฑ (UID 1000์ ์ผ๋ฐ์ ์ธ ๋น-root ์ฌ์ฉ์ ID)
RUN adduser --uid 1000 user
# !!! IMPORTANT: Change ownership of cache directories as root BEFORE switching user !!!
RUN chown -R user:user /tmp/huggingface_cache /tmp/huggingface_home /tmp/matplotlib_cache
# Switch to the non-root user for subsequent commands and application runtime
USER user
# Copy application code after switching user if you want it owned by 'user'
# Or copy it before and then chown it. This approach is usually cleaner.
# $HOME will now resolve to /home/user inside the container
COPY --chown=user . /home/user/app
WORKDIR /home/user/app
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |