update
Browse files1110 unmodified lines111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711488 unmodified lines115711581159116011611162116311641165112811661167116811691110 unmodified lines if not files: return gr.update(value="Error: Could not parse React output. Please regenerate the code.", visible=True) # If Dockerfile is missing, use template if 'Dockerfile' not in files: files['Dockerfile'] = """FROM node:18-slim
# Set up user with ID 1000RUN useradd -m -u 1000 userUSER userENV HOME=/home/user \\ PATH=/home/user/.local/bin:$PATH
# Set working directoryWORKDIR $HOME/app
# Copy package files with proper ownershipCOPY --chown=user package*.json ./
# Install dependenciesRUN npm install
# Copy rest of the application with proper ownershipCOPY --chown=user . .
# Build the Next.js appRUN npm run build
# Expose port 7860EXPOSE 7860
# Start the application on port 7860CMD ["npm", "start", "--", "-p", "7860"]""" # Upload React files import tempfile import time8 unmodified lines for attempt in range(max_attempts): try: # Determine file extension if file_name == 'Dockerfile': suffix = '' else: suffix = f".{file_name.split('.')[-1]}" with tempfile.NamedTemporaryFile("w", suffix=f".{file_name.split('.')[-1]}", delete=False) as f: with tempfile.NamedTemporaryFile("w", suffix=suffix, delete=False) as f: f.write(file_content) temp_path = f.name anycoder_app/ui.py+39-1