File size: 1,793 Bytes
788259d
 
889f722
788259d
 
 
 
889f722
798f326
82460db
798f326
 
82460db
889f722
 
 
e04fb78
 
 
 
 
 
 
119439f
 
 
 
 
 
 
 
 
 
 
 
889f722
 
119439f
 
 
889f722
dc23942
 
889f722
785ec08
 
 
 
 
 
889f722
119439f
889f722
 
 
 
 
 
 
119439f
889f722
 
119439f
889f722
 
 
 
 
 
 
 
119439f
889f722
 
 
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
# Use Python 3.10 as base image
FROM python:3.10-bullseye

# Install Node.js 18
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
    && apt-get install -y nodejs \
    && rm -rf /var/lib/apt/lists/*

# Install uv system-wide
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
RUN cp /root/.local/bin/uv /usr/local/bin/uv
RUN cp /root/.local/bin/uvx /usr/local/bin/uvx

# Install pnpm
RUN npm install -g pnpm

# Set working directory for package installation
WORKDIR /app

# Copy Python requirements and install dependencies as root
COPY requirements.txt .
RUN uv pip install --system --no-cache -r requirements.txt

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Switch to the "user" user
USER user

# Set home to the user's home directory
ENV HOME=/home/user \
	PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy Python files
COPY --chown=user server.py .
COPY --chown=user config.py .
COPY --chown=user features/ ./features/

# Copy frontend files
COPY --chown=user demo ./demo

# Debug: Check what was copied
RUN echo "=== Contents of demo directory after copy ==="
RUN ls -la demo/
RUN echo "=== Check if package.json exists ==="
RUN test -f demo/package.json && echo "package.json exists" || echo "package.json NOT found"

# Install frontend dependencies and build
WORKDIR $HOME/app/demo
RUN pnpm install
RUN pnpm build

# Verify build output
RUN ls -la dist/

# Go back to app directory
WORKDIR $HOME/app

# Copy startup script
COPY --chown=user start.sh .
RUN chmod +x start.sh

# Expose port 7860 for HF Spaces
EXPOSE 7860

# Set environment variables
ENV NODE_ENV=production
ENV FLASK_ENV=production
ENV PYTHONPATH=$HOME/app

# Start both services
CMD ["./start.sh"]