GenAI_VTON_API / Dockerfile
nami0342's picture
Ordering command in dokerfile
0674d0d
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"]