ariansyahdedy commited on
Commit
f2db274
·
1 Parent(s): 2476522

TRY install on system wide

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -17
Dockerfile CHANGED
@@ -1,39 +1,44 @@
1
  FROM python:3.10
2
 
3
- # Install system deps
 
 
4
  RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0
5
 
6
- # Set an env so Poetry installs into /usr/local
 
 
7
  ENV POETRY_HOME="/usr/local/poetry"
8
-
9
  RUN curl -sSL https://install.python-poetry.org | python3 - --yes
10
 
11
- # Add Poetry to the PATH
12
- ENV PATH="/usr/local/poetry/bin:$PATH"
13
-
14
- # Create a non-root user
15
- RUN useradd -m -u 1000 user
16
 
17
- # Use /code as working directory
 
 
18
  WORKDIR /code
19
 
20
- # Copy dependency files
21
  COPY pyproject.toml poetry.lock /code/
22
 
23
- # Install dependencies as root first
24
  RUN poetry install --no-root --no-interaction --no-ansi
25
 
26
- # Now copy the rest of the project
27
  COPY . /code
28
 
29
- # (Optional) Adjust ownership
 
 
 
 
30
  RUN chown -R user:user /code
31
 
32
- # Switch to the non-root user
33
  USER user
34
 
35
- # Expose port
 
 
36
  EXPOSE 7860
37
-
38
- # Run
39
  CMD ["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.10
2
 
3
+ # ---------------------------
4
+ # 1. System dependencies
5
+ # ---------------------------
6
  RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0
7
 
8
+ # ---------------------------
9
+ # 2. Set up Poetry in /usr/local
10
+ # ---------------------------
11
  ENV POETRY_HOME="/usr/local/poetry"
 
12
  RUN curl -sSL https://install.python-poetry.org | python3 - --yes
13
 
14
+ # Add Poetry to PATH
15
+ ENV PATH="$POETRY_HOME/bin:$PATH"
 
 
 
16
 
17
+ # ---------------------------
18
+ # 3. Copy files & install deps
19
+ # ---------------------------
20
  WORKDIR /code
21
 
22
+ # Copy only dependency files first for Docker caching
23
  COPY pyproject.toml poetry.lock /code/
24
 
25
+ # Install dependencies
26
  RUN poetry install --no-root --no-interaction --no-ansi
27
 
28
+ # Copy the rest of the project
29
  COPY . /code
30
 
31
+ # ---------------------------
32
+ # 4. If you need a non-root user
33
+ # ---------------------------
34
+ # (Optional) Create a non-root user
35
+ RUN useradd -m -u 1000 user
36
  RUN chown -R user:user /code
37
 
 
38
  USER user
39
 
40
+ # ---------------------------
41
+ # 5. Expose & run
42
+ # ---------------------------
43
  EXPOSE 7860
 
 
44
  CMD ["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]