@@ -51,7 +51,7 @@ COPY ./src/lfx/pyproject.toml /app/src/lfx/pyproject.toml
5151
5252RUN --mount=type=cache,target=/root/.cache/uv \
5353 RUSTFLAGS='--cfg reqwest_unstable' \
54- uv sync --frozen --no-install-project --no-editable --extra postgresql
54+ uv sync --frozen --no-install-project --no-editable --no-dev -- extra postgresql
5555
5656COPY ./src /app/src
5757
@@ -67,20 +67,70 @@ WORKDIR /app
6767
6868RUN --mount=type=cache,target=/root/.cache/uv \
6969 RUSTFLAGS='--cfg reqwest_unstable' \
70- uv sync --frozen --no-editable --extra postgresql
70+ uv sync --frozen --no-editable --no-dev --extra postgresql
71+
72+ # Clean up build artifacts and unnecessary files before copying to runtime
73+ # This is critical: cleanup must happen BEFORE COPY to avoid creating layers with whiteout markers
74+ RUN cd /app/.venv && \
75+ # Remove test directories and files
76+ find . -type d -name "tests" -exec rm -rf {} + 2>/dev/null || true && \
77+ find . -type d -name "test" -exec rm -rf {} + 2>/dev/null || true && \
78+ find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true && \
79+ # Remove documentation files
80+ find . -type f \( -name "*.md" -o -name "*.rst" \) -delete 2>/dev/null || true && \
81+ find . -path '*/.dist-info' -prune -o -type f \( -name "*.txt" -o -name "*.TXT" \) -print -delete 2>/dev/null || true && \
82+ # Remove C/C++ source and headers (not needed after compilation)
83+ find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" -o -name "*.cc" \) -delete 2>/dev/null || true && \
84+ # Remove Cython source files
85+ find . -type f \( -name "*.pyx" -o -name "*.pxd" -o -name "*.pxi" \) -delete 2>/dev/null || true && \
86+ # Strip debug symbols from shared libraries
87+ find . -name "*.so" -exec strip --strip-unneeded {} \; 2>/dev/null || true && \
88+ # Remove man pages and docs
89+ rm -rf share/man man 2>/dev/null || true
7190
7291# ###############################
7392# RUNTIME
7493# Setup user, utilities and copy the virtual environment only
7594# ###############################
7695FROM python:3.12.12-slim-trixie AS runtime
7796
78-
97+ # Install only essential runtime dependencies:
98+ # - libpq5: PostgreSQL client library (for database connections)
99+ # - curl: Required for Node.js installation
100+ # - Chromium dependencies for Playwright (minimal set for headless operation)
79101RUN apt-get update \
80102 && apt-get upgrade -y \
81- && apt-get install --no-install-recommends -y curl git libpq5 gnupg xz-utils \
103+ && apt-get install --no-install-recommends -y \
104+ libpq5 \
105+ curl \
106+ xz-utils \
107+ # Chromium dependencies
108+ libnss3 \
109+ libnspr4 \
110+ libatk1.0-0t64 \
111+ libatk-bridge2.0-0t64 \
112+ libcups2t64 \
113+ libdrm2 \
114+ libdbus-1-3 \
115+ libxkbcommon0 \
116+ libxcomposite1 \
117+ libxdamage1 \
118+ libxfixes3 \
119+ libxrandr2 \
120+ libgbm1 \
121+ libpango-1.0-0 \
122+ libcairo2 \
123+ libasound2t64 \
124+ libatspi2.0-0t64 \
125+ libxshmfence1 \
126+ # Fonts (using Debian Trixie package names)
127+ fonts-liberation \
128+ fonts-noto-color-emoji \
82129 && apt-get clean \
83130 && rm -rf /var/lib/apt/lists/*
131+
132+ # Install Node.js (needed for MCP servers that use npx)
133+ # Use minimal installation: download pre-built binaries directly
84134RUN ARCH=$(dpkg --print-architecture) \
85135 && if [ "$ARCH" = "amd64" ]; then NODE_ARCH="x64" ; \
86136 elif [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64" ; \
@@ -90,14 +140,19 @@ RUN ARCH=$(dpkg --print-architecture) \
90140 | head -1) \
91141 && curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.xz" \
92142 | tar -xJ -C /usr/local --strip-components=1 \
93- && npm install -g npm@latest \
94- && npm cache clean --force
143+ && npm cache clean --force \
144+ && rm -rf /usr/local/lib/node_modules/npm/docs \
145+ && rm -rf /usr/local/lib/node_modules/npm/man
146+
95147RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data
96148
97149COPY --from=builder --chown=1000 /app/.venv /app/.venv
98150ENV PATH="/app/.venv/bin:$PATH"
99- RUN /app/.venv/bin/pip install --upgrade playwright \
100- && /app/.venv/bin/playwright install
151+
152+ # Install only Chromium browser for Playwright (not all browsers)
153+ # This saves ~1.5GB compared to installing all browsers
154+ # Install without --with-deps since we manually installed dependencies above
155+ RUN /app/.venv/bin/playwright install chromium
101156
102157LABEL org.opencontainers.image.title=langflow
103158LABEL org.opencontainers.image.authors=['Langflow' ]
0 commit comments