Optimize Docker build with multi-stage frontend compilation
• Add frontend build stage to Dockerfile
• Remove --production flag from bun install
• Fix frontend asset integration
(cherry picked from commit e5cbc593f4)
This commit is contained in:
parent
077a2fdbb7
commit
13963775d7
2 changed files with 41 additions and 2 deletions
23
.github/workflows/pypi-publish.yml
vendored
23
.github/workflows/pypi-publish.yml
vendored
|
|
@ -17,6 +17,29 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 0 # Fetch all history for tags
|
||||
|
||||
# Build frontend WebUI
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- name: Build Frontend WebUI
|
||||
run: |
|
||||
cd lightrag_webui
|
||||
bun install --frozen-lockfile
|
||||
bun run build
|
||||
cd ..
|
||||
|
||||
- name: Verify Frontend Build
|
||||
run: |
|
||||
if [ ! -f "lightrag/api/webui/index.html" ]; then
|
||||
echo "❌ Error: Frontend build failed - index.html not found"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Frontend build verified"
|
||||
echo "Frontend files:"
|
||||
ls -lh lightrag/api/webui/ | head -10
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
|
|
|||
20
Dockerfile
20
Dockerfile
|
|
@ -1,4 +1,17 @@
|
|||
# Build stage
|
||||
# Frontend build stage
|
||||
FROM oven/bun:1 AS frontend-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy frontend source code
|
||||
COPY lightrag_webui/ ./lightrag_webui/
|
||||
|
||||
# Build frontend
|
||||
RUN cd lightrag_webui && \
|
||||
bun install --frozen-lockfile && \
|
||||
bun run build
|
||||
|
||||
# Python build stage
|
||||
FROM python:3.12-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
|
@ -20,6 +33,9 @@ COPY pyproject.toml .
|
|||
COPY setup.py .
|
||||
COPY lightrag/ ./lightrag/
|
||||
|
||||
# Copy frontend build output from frontend-builder stage
|
||||
COPY --from=frontend-builder /app/lightrag/api/webui ./lightrag/api/webui
|
||||
|
||||
# Install dependencies
|
||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
RUN pip install --user --no-cache-dir --use-pep517 .
|
||||
|
|
@ -47,7 +63,7 @@ RUN pip install --upgrade pip setuptools wheel
|
|||
|
||||
# Copy only necessary files from builder
|
||||
COPY --from=builder /root/.local /root/.local
|
||||
COPY ./lightrag ./lightrag
|
||||
COPY --from=builder /app/lightrag ./lightrag
|
||||
COPY setup.py .
|
||||
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue