nami0342 commited on
Commit
0674d0d
ยท
1 Parent(s): a0bcc0b

Ordering command in dokerfile

Browse files
Files changed (1) hide show
  1. 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 adduser --uid 1000 user
21
 
22
- USER user
 
23
 
 
24
  RUN chown -R user:user /tmp/huggingface_cache /tmp/huggingface_home /tmp/matplotlib_cache
25
 
26
- # OpenGL ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ (opencv-python ์„ค์น˜ ์ „์—)
27
- RUN apt-get update && apt-get install -y libgl1
28
-
29
- WORKDIR $HOME/app
30
 
31
- COPY --chown=user . $HOME/app
 
 
 
 
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"]