893376dc14
Issues fixed:
1. Web Worker localStorage error - Remove localStorage calls from worker
- Worker cannot access localStorage (browser context only)
- Worker now sends data to main thread via postMessage
- Main thread handles all localStorage operations
2. Add favicon to avoid 404 error
- Use inline SVG favicon (llama emoji)
- No external file request
3. Optimize Tailwind CSS for production
- Add tailwind.config.js for content scanning
- Add app/web/static/css/input.css (Tailwind directives)
- Update package.json with tailwind build commands
- Update Dockerfile multi-stage build:
* Stage 1: Node.js - compile Tailwind CSS
* Stage 2: Python - install dependencies
* Stage 3: Runtime - use compiled CSS
- Update index.html to use compiled output.css
- Add fallback to CDN for development
4. Add DEVELOPMENT.md documentation
- Setup instructions for local development
- Tailwind CSS workflow (watch mode)
- Docker build explanation
- Development tips and best practices
Benefits:
- No more localStorage errors in console
- No more 404 favicon requests
- Optimized CSS for production (~30KB minified)
- Clear development workflow
- Multi-stage Docker build is efficient (~300MB image)
69 lines
1.6 KiB
Docker
69 lines
1.6 KiB
Docker
# Multi-stage build per LLM Monitor
|
|
|
|
# Stage 1: Build CSS with Tailwind
|
|
FROM node:18-alpine as css-builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copiare file di configurazione
|
|
COPY package.json tailwind.config.js ./
|
|
COPY app/web/static/css/input.css ./app/web/static/css/
|
|
|
|
# Installare dipendenze Node
|
|
RUN npm install
|
|
|
|
# Compilare CSS Tailwind
|
|
RUN npm run tailwind:build
|
|
|
|
# Stage 2: Build Python packages
|
|
FROM python:3.11-slim as builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Installare dipendenze di build
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copiare requirements
|
|
COPY requirements.txt .
|
|
|
|
# Installare Python packages in un virtualenv
|
|
RUN python -m venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
|
pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Stage 3: Runtime
|
|
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Installare dipendenze di runtime
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copiare il virtualenv dal builder
|
|
COPY --from=builder /opt/venv /opt/venv
|
|
|
|
# Copiare codice dell'app
|
|
COPY --from=css-builder /app/app/web/static/css/output.css ./app/web/static/css/
|
|
COPY app/ /app/app/
|
|
COPY main.py /app/
|
|
COPY .env* /app/
|
|
|
|
# Impostare PATH
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Esporre la porta
|
|
EXPOSE 8000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8000/api/v1/health || exit 1
|
|
|
|
# Comando di avvio
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|