Spaces:
Sleeping
Sleeping
| 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"] |