adowu commited on
Commit
b258970
·
verified ·
1 Parent(s): 142f0b3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -12
Dockerfile CHANGED
@@ -1,10 +1,10 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.11-slim
3
 
4
- # Set the working directory to /app
5
  WORKDIR /app
6
 
7
- # Install system dependencies for Playwright
8
  RUN apt-get update && apt-get install -y --no-install-recommends \
9
  wget \
10
  unzip \
@@ -29,17 +29,36 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
29
  libx11-6 \
30
  && rm -rf /var/lib/apt/lists/*
31
 
32
- # Copy the current directory contents into the container at /app
33
  COPY . /app/
34
 
35
- # Install any needed packages specified in requirements.txt
36
  RUN pip install --no-cache-dir -r requirements.txt
37
 
38
- # Install Playwright browsers *before* running the script, and use PLAYWRIGHT_BROWSERS_PATH
39
- # This ensures the browsers are installed in a location Playwright can find them.
40
  ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
41
- RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH \
42
- && playwright install chromium --with-deps
43
 
44
- # Run the app when the container launches
45
- CMD ["python", "app.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Wybieramy oficjalny obraz Python jako bazowy
2
+ FROM python:3.11-slim AS base
3
 
4
+ # Ustawiamy katalog roboczy na /app
5
  WORKDIR /app
6
 
7
+ # Instalujemy zależności systemowe dla Playwright
8
  RUN apt-get update && apt-get install -y --no-install-recommends \
9
  wget \
10
  unzip \
 
29
  libx11-6 \
30
  && rm -rf /var/lib/apt/lists/*
31
 
32
+ # Kopiujemy pliki aplikacji do kontenera
33
  COPY . /app/
34
 
35
+ # Instalujemy zależności z requirements.txt
36
  RUN pip install --no-cache-dir -r requirements.txt
37
 
38
+ # Instalujemy przeglądarki Playwright (chromium)
 
39
  ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
40
+ RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH && playwright install chromium --with-deps
 
41
 
42
+ # Tworzymy użytkownika (bez roota)
43
+ RUN useradd -m -u 1000 user
44
+
45
+ # Tworzymy katalogi na dane
46
+ RUN mkdir /data
47
+ RUN chown -R 1000:1000 /app /data
48
+
49
+ # Przełączamy na użytkownika "user"
50
+ USER user
51
+
52
+ # Ustawiamy zmienne środowiskowe
53
+ ENV HOME=/home/user \
54
+ PATH=/home/user/.local/bin:$PATH
55
+
56
+ # Możemy tu zainstalować dodatkowe zależności Node.js, jeśli są potrzebne
57
+ # Jeśli nie są, to pominąć te kroki
58
+
59
+ # Zmieniamy plik entrypoint.sh na wykonywalny
60
+ COPY entrypoint.sh /app/entrypoint.sh
61
+ RUN chmod +x /app/entrypoint.sh
62
+
63
+ # Zdefiniujmy punkt wejścia
64
+ ENTRYPOINT ["/app/entrypoint.sh"]