ariansyahdedy commited on
Commit
7202336
·
1 Parent(s): e8de95e

Fix Dockerfile for Poetry

Browse files
Files changed (2) hide show
  1. Dockerfile +20 -31
  2. indexed_links.txt +5 -0
Dockerfile CHANGED
@@ -1,52 +1,41 @@
1
  FROM python:3.10
2
 
 
 
 
3
  # Install Poetry
4
  RUN curl -sSL https://install.python-poetry.org | python3 -
5
 
6
- # Set PATH
7
  ENV PATH="/root/.local/bin:$PATH"
8
 
9
- # Install dependencies
10
- RUN poetry install --no-root
11
-
12
-
13
- RUN useradd -m -u 1000 user
14
-
15
  WORKDIR /code
16
 
17
- # Install libgl1-mesa-glx and libglib2.0-0
18
- RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0
19
 
20
- COPY ./requirements.txt /code/requirements.txt
 
21
 
22
- RUN python -m venv /code/venv
 
23
 
24
- RUN /code/venv/bin/pip install --no-cache-dir --upgrade -r /code/requirements.txt
25
-
26
- COPY --chown=user . /code
27
-
28
- # Copy the start script into the container and change permissions before switching to non-root user
29
- COPY start.sh /code/start.sh
30
  RUN chmod +x /code/start.sh
31
 
32
  # Create necessary directories and set permissions before switching to non-root user
33
  RUN mkdir -p /code/uploaded_videos /code/output_frames \
34
- && chown -R user:user /code \
35
- && ls -l /code
36
 
37
- USER user
 
38
 
39
- RUN ls -l /code
40
- RUN ls -l /code/output_frames
41
 
42
- ENV PATH="/code/venv/bin:$PATH"
43
-
44
- # Make port 8000 available to the world outside this container
45
  EXPOSE 8000
46
 
47
- # Define environment variable
48
- ENV PYTHONUNBUFFERED=1
49
-
50
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
51
- # Use the start script as the entry point
52
- # CMD ["/code/start.sh"]
 
1
  FROM python:3.10
2
 
3
+ # Install system dependencies
4
+ RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0
5
+
6
  # Install Poetry
7
  RUN curl -sSL https://install.python-poetry.org | python3 -
8
 
9
+ # Set Poetry path (ensures it's available in future RUN commands)
10
  ENV PATH="/root/.local/bin:$PATH"
11
 
12
+ # Set working directory
 
 
 
 
 
13
  WORKDIR /code
14
 
15
+ # Copy Poetry files first to optimize Docker caching
16
+ COPY pyproject.toml poetry.lock /code/
17
 
18
+ # Install dependencies (without installing the root package)
19
+ RUN poetry install --no-root --no-interaction --no-ansi
20
 
21
+ # Copy the rest of the project files
22
+ COPY . /code
23
 
24
+ # Ensure start script is executable
 
 
 
 
 
25
  RUN chmod +x /code/start.sh
26
 
27
  # Create necessary directories and set permissions before switching to non-root user
28
  RUN mkdir -p /code/uploaded_videos /code/output_frames \
29
+ && chown -R 1000:1000 /code
 
30
 
31
+ # Switch to non-root user
32
+ USER 1000
33
 
34
+ # Set Poetry environment for user
35
+ ENV PATH="/home/user/.local/bin:$PATH"
36
 
37
+ # Expose the application port
 
 
38
  EXPOSE 8000
39
 
40
+ # Run the application
41
+ CMD ["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
indexed_links.txt CHANGED
@@ -13,3 +13,8 @@
13
  2025-02-22 21:41:46,472 - INFO - f45fc1f2-5ead-4a94-b3f2-eca2a7e6b851_https://sswalfa.surabaya.go.id/info/detail/pengganti-ipt
14
  2025-02-22 21:41:46,795 - INFO - 80b46ca9-480b-4651-8074-56861488c2e5_https://sswalfa.surabaya.go.id/info/detail/arahan-sistem-drainase
15
  2025-02-22 21:41:47,152 - INFO - 617438e3-472e-4896-8492-4f52d783a401_https://sswalfa.surabaya.go.id/info/detail/rangkaian-pelayanan-surat-pernyataan-belum-menikah-lagi-bagi-jandaduda
 
 
 
 
 
 
13
  2025-02-22 21:41:46,472 - INFO - f45fc1f2-5ead-4a94-b3f2-eca2a7e6b851_https://sswalfa.surabaya.go.id/info/detail/pengganti-ipt
14
  2025-02-22 21:41:46,795 - INFO - 80b46ca9-480b-4651-8074-56861488c2e5_https://sswalfa.surabaya.go.id/info/detail/arahan-sistem-drainase
15
  2025-02-22 21:41:47,152 - INFO - 617438e3-472e-4896-8492-4f52d783a401_https://sswalfa.surabaya.go.id/info/detail/rangkaian-pelayanan-surat-pernyataan-belum-menikah-lagi-bagi-jandaduda
16
+ 2025-02-22 22:12:57,386 - INFO - 35f747e3-db69-4a35-83ce-f65576728574_https://sswalfa.surabaya.go.id/info/detail/izin-pengumpulan-sumbangan-bencana
17
+ 2025-02-22 22:12:57,716 - INFO - 09804822-a2f5-490f-888c-147516e5548b_https://sswalfa.surabaya.go.id/info/detail/izin-pemakaian-ruang-terbuka-hijau
18
+ 2025-02-22 22:12:58,095 - INFO - 38bee6db-29fb-4e45-baa4-e9ce25d72031_https://sswalfa.surabaya.go.id/info/detail/pengganti-ipt
19
+ 2025-02-22 22:12:58,486 - INFO - ecef5ab6-fc45-4bba-83d6-f9ee28b2e816_https://sswalfa.surabaya.go.id/info/detail/arahan-sistem-drainase
20
+ 2025-02-22 22:12:58,811 - INFO - 880edbea-162d-47ab-a98f-211c9a4b4ce2_https://sswalfa.surabaya.go.id/info/detail/rangkaian-pelayanan-surat-pernyataan-belum-menikah-lagi-bagi-jandaduda