SilentWraith commited on
Commit
8c8d5f8
·
verified ·
1 Parent(s): f37cf04

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -30
Dockerfile CHANGED
@@ -1,42 +1,21 @@
1
  # Stage 1: Build
2
- FROM python:3.11-slim as builder
3
 
4
  WORKDIR /app
5
-
6
- # Copy requirements.txt
7
  COPY requirements.txt .
 
8
 
9
- # Install dependencies
10
- RUN pip install --no-cache-dir -r requirements.txt
11
-
12
- # Copy everything
13
- COPY app app
14
-
15
- # Stage 2: Production
16
- FROM python:3.11-slim as production
17
 
18
  WORKDIR /app
19
 
20
- # Copy installed modules from the builder stage
21
- COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
22
 
23
- # Install playwright dependencies
24
- RUN python -m playwright install-deps && \
25
- # Clean up
26
- rm -f /usr/lib/x86_64-linux-gnu/libmfxhw* /usr/lib/x86_64-linux-gnu/mfx/* && \
27
- # Create non-root user
28
- useradd --home-dir /app --shell /bin/sh zaws && \
29
- chown -R zaws:zaws .
30
 
31
- # Switch to non-root user
32
  USER zaws
33
 
34
- # Installfirefox inside non-root
35
- # Do not install firefox in root to avoid permission error otherwise you need to give zaws permission to access installation path
36
- RUN python -m playwright install firefox
37
-
38
- # Copy application code from the builder stage
39
- COPY --from=builder /app /app
40
-
41
- # Run application
42
- CMD ["python", "app/main.py"]
 
1
  # Stage 1: Build
2
+ FROM python:3.11-bookworm AS builder
3
 
4
  WORKDIR /app
 
 
5
  COPY requirements.txt .
6
+ RUN pip install --prefix=/install --no-cache-dir -r requirements.txt
7
 
8
+ # Stage 2: Runtime
9
+ FROM mcr.microsoft.com/playwright/python:v1.42.0-jammy
 
 
 
 
 
 
10
 
11
  WORKDIR /app
12
 
13
+ COPY --from=builder /install /usr/local
14
+ COPY app app
15
 
16
+ RUN useradd --home-dir /app --shell /bin/sh zaws && \
17
+ chown -R zaws:zaws /app
 
 
 
 
 
18
 
 
19
  USER zaws
20
 
21
+ CMD ["python", "app/main.py"]