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