akhaliq HF Staff commited on
Commit
ede0c7c
·
1 Parent(s): a6cd23f
Files changed (2) hide show
  1. anycoder_app/prompts.py +13 -29
  2. anycoder_app/ui.py +8 -15
anycoder_app/prompts.py CHANGED
@@ -296,54 +296,38 @@ module.exports = nextConfig
296
 
297
  Dockerfile Requirements (CRITICAL for HuggingFace Spaces):
298
  - Use Node.js 18+ base image (e.g., FROM node:18-slim)
299
- - Set up a user with ID 1000 for proper permissions:
300
- ```
301
- RUN useradd -m -u 1000 user
302
- USER user
303
- ENV HOME=/home/user \\
304
- PATH=/home/user/.local/bin:$PATH
305
- WORKDIR $HOME/app
306
- ```
307
- - ALWAYS use --chown=user with COPY and ADD commands:
308
- ```
309
- COPY --chown=user package*.json ./
310
- COPY --chown=user . .
311
- ```
312
  - Install dependencies: RUN npm install
 
313
  - Build the app: RUN npm run build
314
  - Expose port 7860 (HuggingFace Spaces default): EXPOSE 7860
 
315
  - Start with: CMD ["npm", "start", "--", "-p", "7860"]
316
- - If using a different port, make sure to set app_port in the README.md YAML frontmatter
317
 
318
  Example Dockerfile structure:
319
  ```dockerfile
320
  FROM node:18-slim
321
 
322
- # Set up user with ID 1000
323
- RUN useradd -m -u 1000 user
324
- USER user
325
- ENV HOME=/home/user \\
326
- PATH=/home/user/.local/bin:$PATH
327
 
328
- # Set working directory
329
- WORKDIR $HOME/app
 
330
 
331
- # Copy package files with proper ownership
332
- COPY --chown=user package*.json ./
333
 
334
- # Install dependencies
335
  RUN npm install
336
 
337
- # Copy rest of the application with proper ownership
338
- COPY --chown=user . .
339
 
340
- # Build the Next.js app
341
  RUN npm run build
342
 
343
- # Expose port 7860
344
  EXPOSE 7860
345
 
346
- # Start the application on port 7860
 
347
  CMD ["npm", "start", "--", "-p", "7860"]
348
  ```
349
 
 
296
 
297
  Dockerfile Requirements (CRITICAL for HuggingFace Spaces):
298
  - Use Node.js 18+ base image (e.g., FROM node:18-slim)
299
+ - Set working directory: WORKDIR /app
300
+ - Install system dependencies (curl for healthcheck)
301
+ - Copy package files: COPY package*.json ./
 
 
 
 
 
 
 
 
 
 
302
  - Install dependencies: RUN npm install
303
+ - Copy application files: COPY . .
304
  - Build the app: RUN npm run build
305
  - Expose port 7860 (HuggingFace Spaces default): EXPOSE 7860
306
+ - Add healthcheck: HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
307
  - Start with: CMD ["npm", "start", "--", "-p", "7860"]
 
308
 
309
  Example Dockerfile structure:
310
  ```dockerfile
311
  FROM node:18-slim
312
 
313
+ WORKDIR /app
 
 
 
 
314
 
315
+ RUN apt-get update && apt-get install -y \
316
+ curl \
317
+ && rm -rf /var/lib/apt/lists/*
318
 
319
+ COPY package*.json ./
 
320
 
 
321
  RUN npm install
322
 
323
+ COPY . .
 
324
 
 
325
  RUN npm run build
326
 
 
327
  EXPOSE 7860
328
 
329
+ HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
330
+
331
  CMD ["npm", "start", "--", "-p", "7860"]
332
  ```
333
 
anycoder_app/ui.py CHANGED
@@ -1115,31 +1115,24 @@ with gr.Blocks(
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
 
 
1115
  if 'Dockerfile' not in files:
1116
  files['Dockerfile'] = """FROM node:18-slim
1117
 
1118
+ WORKDIR /app
 
 
 
 
1119
 
1120
+ RUN apt-get update && apt-get install -y \\
1121
+ curl \\
1122
+ && rm -rf /var/lib/apt/lists/*
1123
 
1124
+ COPY package*.json ./
 
1125
 
 
1126
  RUN npm install
1127
 
1128
+ COPY . .
 
1129
 
 
1130
  RUN npm run build
1131
 
 
1132
  EXPOSE 7860
1133
 
1134
+ HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
1135
+
1136
  CMD ["npm", "start", "--", "-p", "7860"]
1137
  """
1138