1- # Use the official Python image from Docker Hub
2- # Use the official Python image from Docker Hub
3- FROM python:3.11
1+ FROM python:3.11 as builder
42
53# Set the working directory inside the container
64WORKDIR /app
75
8- # Install dependencies
6+ # Install build dependencies
97RUN apt-get update && apt-get install -y \
108 sudo \
119 wget \
12- gettext
10+ gettext \
11+ && rm -rf /var/lib/apt/lists/*
12+
13+ RUN python -m venv /opt/venv
14+ ENV PATH="/opt/venv/bin:$PATH"
15+
16+ # Install Python packages
17+ RUN pip install --upgrade pip
18+ COPY ./requirements.prod.txt .
19+ RUN pip install -r requirements.prod.txt
20+
21+ # Download Python source for internationalization
22+ RUN wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz \
23+ && tar xzf Python-3.11.0.tgz \
24+ && mv Python-3.11.0 /usr/local/src/ \
25+ && rm Python-3.11.0.tgz
26+
27+ # Copy application code and compile messages
28+ COPY . .
29+ RUN chmod +x /usr/local/src/Python-3.11.0/Tools/i18n/msgfmt.py
30+ RUN /usr/local/src/Python-3.11.0/Tools/i18n/msgfmt.py /app/locale/de/LC_MESSAGES/base.po /app/locale/de/LC_MESSAGES/base
31+
32+ # Final stage
33+ FROM python:3.11-slim
1334
35+ # Set the working directory
36+ WORKDIR /app
1437
15- # Playwright system dependencies for Linux
38+ # Install runtime dependencies
1639RUN apt-get update && apt-get install -y --no-install-recommends \
1740 libglib2.0-0 \
1841 libnss3 \
@@ -37,30 +60,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3760 libatspi2.0-0 \
3861 && rm -rf /var/lib/apt/lists/*
3962
40- RUN pip install --upgrade pip
41- COPY ./requirements.prod.txt .
42- RUN pip install -r requirements.prod.txt
43- RUN playwright install
44- RUN crawl4ai-setup
45-
46-
47- # Download Python source (Needed for internationalization)
48- RUN wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz \
49- && tar xzf Python-3.11.0.tgz \
50- && mv Python-3.11.0 /usr/local/src/ \
51- && rm Python-3.11.0.tgz
63+ # Copy only necessary files from builder
5264
65+ COPY --from=builder /opt/venv /opt/venv
66+ ENV PATH="/opt/venv/bin:$PATH"
67+ COPY --from=builder /app/locale /app/locale
68+ COPY --from=builder /app /app
5369
5470
55- # Copy the rest of the application code into the container
56- COPY . .
57-
58- # Compile the .po file into a .mo file
59- #RUN ls -l /usr/local/src/Python-3.11.0/Tools/i18n/msgfmt.py
60- RUN chmod +x /usr/local/src/Python-3.11.0/Tools/i18n/msgfmt.py
61- RUN /usr/local/src/Python-3.11.0/Tools/i18n/msgfmt.py /app/locale/de/LC_MESSAGES/base.po /app/locale/de/LC_MESSAGES/base
71+ RUN echo $PATH
72+ RUN echo $(which python)
6273
6374
75+ # Install Playwright browsers
76+ RUN playwright install
77+ RUN crawl4ai-setup
6478# Expose the port that Streamlit will run on
6579EXPOSE 8501
6680
0 commit comments