UnknownPixel/askPESU
0
1# Multi-stage build for frontend and backend
2FROM node:24-alpine AS frontend-builder
3
4# Set working directory for frontend
5WORKDIR /app/frontend
6
7# Copy frontend package files
8COPY frontend/package*.json ./
9
10# Install frontend dependencies (including dev dependencies for build)
11RUN npm ci
12
13# Copy frontend source code
14COPY frontend/ ./
15
16# Build the frontend for production
17RUN npm run build
18
19# Python backend stage
20FROM python:3.12-slim-bookworm
21
22# Set working directory
23WORKDIR /app
24
25# Copy the app and config files
26COPY app /app/app
27COPY conf /app/conf
28COPY requirements.txt /app/requirements.txt
29
30# Copy .env if it exists
31COPY .env* /app/
32
33# Copy the built frontend files from the frontend stage
34COPY --from=frontend-builder /app/frontend/out frontend/out
35
36# Set Hugging Face cache directory
37RUN mkdir -p /app/.cache/huggingface
38RUN chmod -R 777 /app/.cache
39ENV HF_HOME=/app/.cache/huggingface
40
41# Set Torch cache directory
42ENV TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_cache
43
44# Add fake user entry so getpass.getuser() works
45RUN echo "user:x:1000:1000:user:/home/user:/bin/bash" >> /etc/passwd && mkdir -p /home/user
46
47# Install dependencies
48RUN pip install -r requirements.txt
49
50# Set Python path to include the app directory
51ENV PYTHONPATH=/app
52
53CMD ["python", "-m", "app.app"]
54 