-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.render
More file actions
90 lines (67 loc) · 2.21 KB
/
Dockerfile.render
File metadata and controls
90 lines (67 loc) · 2.21 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Multi-stage Dockerfile for Render deployment
# This Dockerfile builds both the backend API and frontend, then serves them with nginx
# Stage 1: Build Frontend
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
# Install all dependencies (including devDependencies for build)
RUN npm ci
# Copy frontend source code
COPY frontend/ .
# Build the frontend
RUN npx vite build
# Stage 2: Build Backend
FROM python:3.11-slim AS backend-builder
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
tesseract-ocr \
tesseract-ocr-eng \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend source code
COPY scripts/ ./scripts/
COPY app/ ./app/
COPY data/ ./data/
# Stage 3: Production Image
FROM python:3.11-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
tesseract-ocr \
tesseract-ocr-eng \
nginx \
&& rm -rf /var/lib/apt/lists/*
# Copy Python dependencies from backend builder
COPY --from=backend-builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=backend-builder /usr/local/bin /usr/local/bin
# Copy backend application
COPY --from=backend-builder /app/scripts ./scripts/
COPY --from=backend-builder /app/app ./app/
COPY --from=backend-builder /app/data ./data/
# Copy built frontend from frontend builder
COPY --from=frontend-builder /app/frontend/dist /var/www/html
# Create necessary directories
RUN mkdir -p /var/data/index /var/log/nginx
# Set environment variables for Render
ENV PYTHONPATH=/app
ENV DATA_DIR=/var/data
ENV INDEX_DIR=/var/data/index
ENV CHAT_MODEL=gpt-4o-mini
ENV EMBEDDING_MODEL=text-embedding-3-large
ENV PORT=10000
# Copy nginx configuration for production
COPY nginx.render.conf /etc/nginx/sites-available/default
# Copy startup script
COPY docker-entrypoint.render.sh .
RUN chmod +x docker-entrypoint.render.sh
# Expose the port that Render will use
EXPOSE 10000
# Use the startup script
CMD ["./docker-entrypoint.render.sh"]