akhaliq HF Staff commited on
Commit
24bc760
·
1 Parent(s): 9007f56

update react app

Browse files
Files changed (2) hide show
  1. anycoder_app/prompts.py +28 -14
  2. anycoder_app/ui.py +15 -9
anycoder_app/prompts.py CHANGED
@@ -327,39 +327,53 @@ module.exports = nextConfig
327
 
328
  Dockerfile Requirements (CRITICAL for HuggingFace Spaces):
329
  - Use Node.js 18+ base image (e.g., FROM node:18-slim)
330
- - Set working directory: WORKDIR /app
331
- - Install system dependencies (curl for healthcheck)
332
- - Copy package files: COPY package*.json ./
 
 
 
 
 
 
 
 
 
 
333
  - Install dependencies: RUN npm install
334
- - Copy application files: COPY . .
335
  - Build the app: RUN npm run build
336
  - Expose port 7860 (HuggingFace Spaces default): EXPOSE 7860
337
- - Add healthcheck: HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
338
  - Start with: CMD ["npm", "start", "--", "-p", "7860"]
339
 
340
  Example Dockerfile structure:
341
  ```dockerfile
342
  FROM node:18-slim
343
 
344
- WORKDIR /app
 
 
 
 
345
 
346
- # Install system dependencies
347
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
348
- curl \
349
- && rm -rf /var/lib/apt/lists/*
350
 
351
- COPY package*.json ./
 
352
 
 
353
  RUN npm install
354
 
355
- COPY . .
 
356
 
 
357
  RUN npm run build
358
 
 
359
  EXPOSE 7860
360
 
361
- HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
362
-
363
  CMD ["npm", "start", "--", "-p", "7860"]
364
  ```
365
 
 
327
 
328
  Dockerfile Requirements (CRITICAL for HuggingFace Spaces):
329
  - Use Node.js 18+ base image (e.g., FROM node:18-slim)
330
+ - Set up a user with ID 1000 for proper permissions:
331
+ ```
332
+ RUN useradd -m -u 1000 user
333
+ USER user
334
+ ENV HOME=/home/user \\
335
+ PATH=/home/user/.local/bin:$PATH
336
+ WORKDIR $HOME/app
337
+ ```
338
+ - ALWAYS use --chown=user with COPY and ADD commands:
339
+ ```
340
+ COPY --chown=user package*.json ./
341
+ COPY --chown=user . .
342
+ ```
343
  - Install dependencies: RUN npm install
 
344
  - Build the app: RUN npm run build
345
  - Expose port 7860 (HuggingFace Spaces default): EXPOSE 7860
 
346
  - Start with: CMD ["npm", "start", "--", "-p", "7860"]
347
 
348
  Example Dockerfile structure:
349
  ```dockerfile
350
  FROM node:18-slim
351
 
352
+ # Set up user with ID 1000
353
+ RUN useradd -m -u 1000 user
354
+ USER user
355
+ ENV HOME=/home/user \\
356
+ PATH=/home/user/.local/bin:$PATH
357
 
358
+ # Set working directory
359
+ WORKDIR $HOME/app
 
 
360
 
361
+ # Copy package files with proper ownership
362
+ COPY --chown=user package*.json ./
363
 
364
+ # Install dependencies
365
  RUN npm install
366
 
367
+ # Copy rest of the application with proper ownership
368
+ COPY --chown=user . .
369
 
370
+ # Build the Next.js app
371
  RUN npm run build
372
 
373
+ # Expose port 7860
374
  EXPOSE 7860
375
 
376
+ # Start the application on port 7860
 
377
  CMD ["npm", "start", "--", "-p", "7860"]
378
  ```
379
 
anycoder_app/ui.py CHANGED
@@ -1115,25 +1115,31 @@ with gr.Blocks(
1115
  if 'Dockerfile' not in files:
1116
  files['Dockerfile'] = """FROM node:18-slim
1117
 
1118
- WORKDIR /app
 
 
 
 
1119
 
1120
- # Install system dependencies
1121
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \\
1122
- curl \\
1123
- && rm -rf /var/lib/apt/lists/*
1124
 
1125
- COPY package*.json ./
 
1126
 
 
1127
  RUN npm install
1128
 
1129
- COPY . .
 
1130
 
 
1131
  RUN npm run build
1132
 
 
1133
  EXPOSE 7860
1134
 
1135
- HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
1136
-
1137
  CMD ["npm", "start", "--", "-p", "7860"]
1138
  """
1139
 
 
1115
  if 'Dockerfile' not in files:
1116
  files['Dockerfile'] = """FROM node:18-slim
1117
 
1118
+ # Set up user with ID 1000
1119
+ RUN useradd -m -u 1000 user
1120
+ USER user
1121
+ ENV HOME=/home/user \\
1122
+ PATH=/home/user/.local/bin:$PATH
1123
 
1124
+ # Set working directory
1125
+ WORKDIR $HOME/app
 
 
1126
 
1127
+ # Copy package files with proper ownership
1128
+ COPY --chown=user package*.json ./
1129
 
1130
+ # Install dependencies
1131
  RUN npm install
1132
 
1133
+ # Copy rest of the application with proper ownership
1134
+ COPY --chown=user . .
1135
 
1136
+ # Build the Next.js app
1137
  RUN npm run build
1138
 
1139
+ # Expose port 7860
1140
  EXPOSE 7860
1141
 
1142
+ # Start the application on port 7860
 
1143
  CMD ["npm", "start", "--", "-p", "7860"]
1144
  """
1145