gaialive commited on
Commit
9a42d1f
·
verified ·
1 Parent(s): 64ae76d

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +5 -32
  2. startup.sh +3 -4
Dockerfile CHANGED
@@ -20,16 +20,6 @@ RUN npm run build
20
  # Production image
21
  FROM node:18-alpine
22
 
23
- # Install nginx
24
- RUN apk add --no-cache nginx
25
-
26
- # Configure nginx to redirect logs to stdout/stderr and remove duplicate directives
27
- RUN sed -i 's/error_log.*/error_log \/dev\/stderr error;/' /etc/nginx/nginx.conf && \
28
- sed -i 's/access_log.*/access_log \/dev\/stdout;/' /etc/nginx/nginx.conf && \
29
- sed -i 's/user nginx;//' /etc/nginx/nginx.conf && \
30
- sed -i '/pid/d' /etc/nginx/nginx.conf && \
31
- sed -i '/daemon off;/d' /etc/nginx/nginx.conf
32
-
33
  # Create app directory
34
  WORKDIR /app
35
 
@@ -42,34 +32,17 @@ RUN npm install --only=production
42
  # Copy server source
43
  COPY server/ ./
44
 
45
- # Create directory for nginx and copy client build
46
- RUN mkdir -p /usr/share/nginx/html
47
- COPY --from=client-builder /app/dist /usr/share/nginx/html
48
-
49
- # Copy nginx configuration
50
- COPY client/nginx.conf /etc/nginx/http.d/default.conf
51
-
52
- # Copy startup script
53
- COPY startup.sh .
54
-
55
- # Make startup script executable
56
- RUN chmod +x startup.sh
57
 
58
  # Set environment variables for Hugging Face Spaces
59
  ENV HF_SPACES=true
60
  ENV PORT=8501
61
  ENV NODE_ENV=production
62
 
63
- # Create nginx directories with proper permissions
64
- RUN mkdir -p /var/lib/nginx/tmp/client_body /var/lib/nginx/tmp/proxy /var/lib/nginx/tmp/fastcgi /var/lib/nginx/tmp/uwsgi /var/lib/nginx/tmp/scgi && \
65
- chmod -R 755 /var/lib/nginx && \
66
- chown -R nginx:nginx /var/lib/nginx && \
67
- mkdir -p /run/nginx && \
68
- chown -R nginx:nginx /run/nginx && \
69
- chown -R nginx:nginx /usr/share/nginx/html
70
-
71
  # Expose port 8501 for Hugging Face Spaces
72
  EXPOSE 8501
73
 
74
- # Start both nginx and node server
75
- CMD ["./startup.sh"]
 
20
  # Production image
21
  FROM node:18-alpine
22
 
 
 
 
 
 
 
 
 
 
 
23
  # Create app directory
24
  WORKDIR /app
25
 
 
32
  # Copy server source
33
  COPY server/ ./
34
 
35
+ # Copy client build to public directory
36
+ RUN mkdir -p public
37
+ COPY --from=client-builder /app/dist public
 
 
 
 
 
 
 
 
 
38
 
39
  # Set environment variables for Hugging Face Spaces
40
  ENV HF_SPACES=true
41
  ENV PORT=8501
42
  ENV NODE_ENV=production
43
 
 
 
 
 
 
 
 
 
44
  # Expose port 8501 for Hugging Face Spaces
45
  EXPOSE 8501
46
 
47
+ # Start the Node.js server
48
+ CMD ["node", "index.js"]
startup.sh CHANGED
@@ -1,10 +1,9 @@
1
  #!/bin/sh
2
 
3
- # Start the Node.js server in the background
4
- node index.js > /dev/null 2>&1 &
5
- NODE_PID=$!
6
 
7
- # Give the server a moment to start
8
  sleep 3
9
 
10
  # Start nginx in the foreground
 
1
  #!/bin/sh
2
 
3
+ # Start the Node.js server
4
+ node index.js
 
5
 
6
+ # Givethe server a moment to start
7
  sleep 3
8
 
9
  # Start nginx in the foreground