File size: 1,368 Bytes
a1e0cbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use official Node.js 22 Slim as the base image
FROM node:22-slim

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    python3-pip \
    python3-venv \
    git \
    curl \
    ca-certificates \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Set up user with UID 1000 (standard for Hugging Face)
RUN useradd -m -u 1000 user
WORKDIR /home/user/app

# Set up npm global folder in user's home directory to avoid permission issues
ENV NPM_CONFIG_PREFIX=/home/user/.npm-global
ENV PATH=$PATH:/home/user/.npm-global/bin

# Set environment variables for Python
ENV PYTHONUNBUFFERED=1

# Install python dependencies system-wide (using --break-system-packages to bypass PEP 668)
RUN pip3 install gradio huggingface_hub --break-system-packages

# Copy the app source code
COPY --chown=user:user app.py /home/user/app/app.py

# Switch to the non-root user
USER user

# Install qwen-code globally under the user's npm directory
RUN npm install -g @qwen-code/qwen-code@latest

# Initialize workspace folder and pre-configure git to avoid interactive prompts
RUN mkdir -p /home/user/app/workspace \
    && git config --global user.name "Qwen Code Demo" \
    && git config --global user.email "demo@qwen.ai"

# Expose port 7860 (Hugging Face default)
EXPOSE 7860

# Run the app
CMD ["python3", "app.py"]