mirror of
https://github.com/vndangkhoa/purestream.git
synced 2026-04-05 01:17:58 +07:00
71 lines
1.6 KiB
Docker
71 lines
1.6 KiB
Docker
# Build stage for frontend
|
|
FROM node:20-alpine AS frontend-builder
|
|
WORKDIR /app/frontend
|
|
COPY frontend/package*.json ./
|
|
RUN npm ci
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM python:3.11-slim
|
|
|
|
# Install system dependencies for Playwright and yt-dlp
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
wget \
|
|
curl \
|
|
gnupg \
|
|
ca-certificates \
|
|
ffmpeg \
|
|
# Playwright dependencies
|
|
libnss3 \
|
|
libnspr4 \
|
|
libatk1.0-0 \
|
|
libatk-bridge2.0-0 \
|
|
libcups2 \
|
|
libdrm2 \
|
|
libxkbcommon0 \
|
|
libxcomposite1 \
|
|
libxdamage1 \
|
|
libxfixes3 \
|
|
libxrandr2 \
|
|
libgbm1 \
|
|
libasound2 \
|
|
libpango-1.0-0 \
|
|
libcairo2 \
|
|
libatspi2.0-0 \
|
|
libgtk-3-0 \
|
|
fonts-liberation \
|
|
xvfb \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy backend requirements and install
|
|
COPY backend/requirements.txt ./
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Install Playwright browsers
|
|
RUN playwright install chromium
|
|
|
|
# Copy backend code
|
|
COPY backend/ ./backend/
|
|
|
|
# Copy built frontend
|
|
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
|
|
|
|
# Create cache directory
|
|
RUN mkdir -p /app/cache && chmod 777 /app/cache
|
|
|
|
# Environment variables
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV CACHE_DIR=/app/cache
|
|
|
|
# Expose port
|
|
EXPOSE 8002
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
CMD curl -f http://localhost:8002/health || exit 1
|
|
|
|
# Start the application with xvfb for headless browser support
|
|
CMD ["sh", "-c", "xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' python -m uvicorn backend.main:app --host 0.0.0.0 --port 8002"]
|