-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (44 loc) · 1.46 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (44 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# ── Stage 1: Build Python dependencies ──
FROM python:3.11-slim AS python-builder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ffmpeg \
libsm6 \
libxext6 \
libgl1 \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --upgrade pip && pip install --user --no-cache-dir -r requirements.txt
# ── Stage 2: Build frontend ──
FROM node:20-slim AS frontend-builder
WORKDIR /frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# ── Stage 3: Production image ──
FROM python:3.11-slim
# Install runtime dependencies for moviepy/opencv
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libsm6 \
libxext6 \
libgl1 \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r appuser && useradd -r -g appuser -d /app appuser
WORKDIR /app
# Copy installed Python packages from builder
COPY --from=python-builder /root/.local /home/appuser/.local
ENV PATH=/home/appuser/.local/bin:$PATH
ENV PYTHONPATH=/home/appuser/.local/lib/python3.11/site-packages:$PYTHONPATH
# Copy application code
COPY . .
# Copy built frontend from frontend-builder
COPY --from=frontend-builder /frontend/dist ./frontend/dist
# Ensure output directories exist and are writable
RUN mkdir -p data/generated_docs data/generated_ads \
&& chown -R appuser:appuser /app
USER appuser
EXPOSE 8080
CMD ["python", "main.py"]