anuragshas commited on
Commit
6c771b7
·
1 Parent(s): bd2fd0b

add: huggingface docker

Browse files
Files changed (3) hide show
  1. Dockerfile +9 -17
  2. nginx.hf.conf +0 -67
  3. package.json +3 -1
Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
- # Stage 1: Build stage
2
- FROM node:22-alpine AS builder
3
 
4
  # Set working directory
5
  WORKDIR /app
@@ -7,8 +7,8 @@ WORKDIR /app
7
  # Copy package files
8
  COPY package*.json ./
9
 
10
- # Install dependencies
11
- RUN npm ci --only=production=false
12
 
13
  # Copy source code
14
  COPY . .
@@ -16,20 +16,12 @@ COPY . .
16
  # Build the application
17
  RUN npm run build
18
 
19
- # Stage 2: Production stage for Hugging Face Spaces
20
- FROM nginx:alpine AS production
21
-
22
- # Install wget for healthcheck
23
- RUN apk add --no-cache wget
24
-
25
- # Copy built application from builder stage
26
- COPY --from=builder /app/dist /usr/share/nginx/html
27
-
28
- # Copy custom nginx configuration for HF Spaces
29
- COPY nginx.hf.conf /etc/nginx/nginx.conf
30
 
31
  # Expose port 7860 (required by Hugging Face Spaces)
32
  EXPOSE 7860
33
 
34
- # Start nginx on port 7860
35
- CMD ["nginx", "-g", "daemon off;"]
 
 
 
1
+ # Use Node.js 22 Alpine as base image
2
+ FROM node:22-alpine
3
 
4
  # Set working directory
5
  WORKDIR /app
 
7
  # Copy package files
8
  COPY package*.json ./
9
 
10
+ # Install all dependencies (including express for production)
11
+ RUN npm ci
12
 
13
  # Copy source code
14
  COPY . .
 
16
  # Build the application
17
  RUN npm run build
18
 
19
+ # Hugging Face Spaces handles user management automatically
 
 
 
 
 
 
 
 
 
 
20
 
21
  # Expose port 7860 (required by Hugging Face Spaces)
22
  EXPOSE 7860
23
 
24
+ # Health check removed for HF Spaces compatibility
25
+
26
+ # Start the application
27
+ CMD ["npm", "start"]
nginx.hf.conf DELETED
@@ -1,67 +0,0 @@
1
- # Set PID file location to writable directory
2
- pid /tmp/nginx.pid;
3
-
4
- events {
5
- worker_connections 1024;
6
- }
7
-
8
- http {
9
- include /etc/nginx/mime.types;
10
- default_type application/octet-stream;
11
-
12
- # Logging
13
- access_log /var/log/nginx/access.log;
14
- error_log /var/log/nginx/error.log;
15
-
16
- # Gzip compression
17
- gzip on;
18
- gzip_vary on;
19
- gzip_min_length 1024;
20
- gzip_proxied any;
21
- gzip_comp_level 6;
22
- gzip_types
23
- text/plain
24
- text/css
25
- text/xml
26
- text/javascript
27
- application/javascript
28
- application/xml+rss
29
- application/json;
30
-
31
- # Security headers
32
- add_header X-Frame-Options "SAMEORIGIN" always;
33
- add_header X-XSS-Protection "1; mode=block" always;
34
- add_header X-Content-Type-Options "nosniff" always;
35
- add_header Referrer-Policy "no-referrer-when-downgrade" always;
36
- add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
37
-
38
- server {
39
- listen 7860;
40
- server_name _;
41
- root /usr/share/nginx/html;
42
- index index.html;
43
-
44
- # Cache static assets
45
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
46
- expires 1y;
47
- add_header Cache-Control "public, immutable";
48
- }
49
-
50
- # Handle SPA routing
51
- location / {
52
- try_files $uri $uri/ /index.html;
53
- }
54
-
55
- # Health check endpoint for HF Spaces
56
- location /health {
57
- access_log off;
58
- return 200 "healthy\n";
59
- add_header Content-Type text/plain;
60
- }
61
-
62
- # Security
63
- location ~ /\. {
64
- deny all;
65
- }
66
- }
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
package.json CHANGED
@@ -6,6 +6,7 @@
6
  "prepare": "husky",
7
  "dev": "parcel index.html",
8
  "build": "parcel build index.html",
 
9
  "lint:js": "eslint script.js tests",
10
  "lint": "npm run lint:js",
11
  "test": "node tests/test.js"
@@ -29,6 +30,7 @@
29
  "dependencies": {
30
  "@tailwindcss/postcss": "^4.1.11",
31
  "postcss": "^8.5.6",
32
- "tailwindcss": "^4.1.11"
 
33
  }
34
  }
 
6
  "prepare": "husky",
7
  "dev": "parcel index.html",
8
  "build": "parcel build index.html",
9
+ "start": "node server.js",
10
  "lint:js": "eslint script.js tests",
11
  "lint": "npm run lint:js",
12
  "test": "node tests/test.js"
 
30
  "dependencies": {
31
  "@tailwindcss/postcss": "^4.1.11",
32
  "postcss": "^8.5.6",
33
+ "tailwindcss": "^4.1.11",
34
+ "express": "^4.18.2"
35
  }
36
  }