-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (40 loc) · 1.13 KB
/
Dockerfile
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
# Stage 1: Build the frontend
FROM node:18 AS frontend-builder
WORKDIR /app
RUN mkdir -p /app/public
WORKDIR /app/frontend
# Copy the frontend source code
COPY frontend .
# Install dependencies and build the frontend
RUN npm install
RUN npm run build
# Stage 2: Build the backend
FROM python:3.11-slim AS backend-builder
ENV PYTHONUNBUFFERED 1
WORKDIR /app
# Enable venv
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy the backend source code
COPY templates ./templates/
COPY chain.py embedding.py llm.py meta.py server.py main.py ./
COPY requirements.txt .
# Install backend dependencies
RUN pip install -Ur requirements.txt
# Stage 3: Final image
FROM python:3.11-slim
WORKDIR /app
# Copy the built frontend from the frontend-builder stage
COPY --from=frontend-builder /app/public ./public
# Copy the built backend from the backend-builder stage
COPY --from=backend-builder /opt/venv /opt/venv
COPY --from=backend-builder /app .
# Expose the backend port
ENV PATH="/opt/venv/bin:$PATH"
ENV HOST="0.0.0.0"
ENV PORT="80"
ENV LOCAL="0"
ENV ENV="production"
EXPOSE 80
# Start the backend server
CMD ["python3", "main.py"]