gaialive commited on
Commit
c719f43
·
verified ·
1 Parent(s): 2a84089

Upload 2 files

Browse files
Files changed (2) hide show
  1. client/Dockerfile +49 -18
  2. client/startup.sh +11 -0
client/Dockerfile CHANGED
@@ -1,32 +1,63 @@
1
- # Use Node.js runtime for building
2
- FROM node:18-alpine AS builder
 
 
3
 
4
- # Set working directory
5
  WORKDIR /app
6
 
7
- # Copy package files
8
- COPY package*.json ./
9
 
10
- # Install dependencies
11
  RUN npm install
12
 
13
- # Copy application code
14
- COPY . .
15
 
16
- # Build the application
17
  RUN npm run build
18
 
19
- # Use nginx to serve the static files
20
- FROM nginx:alpine
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- # Copy built files to nginx
23
- COPY --from=builder /app/dist /usr/share/nginx/html
 
 
 
 
24
 
25
  # Copy nginx configuration
26
- COPY nginx.conf /etc/nginx/nginx.conf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- # Expose port
29
- EXPOSE 80
30
 
31
- # Start nginx
32
- CMD ["nginx", "-g", "daemon off;"]
 
1
+ # Multi-stage Dockerfile for BioNexus Hub
2
+
3
+ # Build the client
4
+ FROM node:18-alpine AS client-builder
5
 
 
6
  WORKDIR /app
7
 
8
+ # Copy client package files
9
+ COPY client/package*.json ./
10
 
11
+ # Install client dependencies
12
  RUN npm install
13
 
14
+ # Copy client source
15
+ COPY client/ ./
16
 
17
+ # Build client
18
  RUN npm run build
19
 
20
+ # Production image
21
+ FROM node:18-alpine
22
+
23
+ # Install nginx
24
+ RUN apk add --no-cache nginx
25
+
26
+ # Create app directory
27
+ WORKDIR /app
28
+
29
+ # Copy package files for server
30
+ COPY server/package*.json ./
31
+
32
+ # Install server dependencies
33
+ RUN npm install --only=production
34
 
35
+ # Copy server source
36
+ COPY server/ ./
37
+
38
+ # Create directory for nginx and copy client build
39
+ RUN mkdir -p /usr/share/nginx/html
40
+ COPY --from=client-builder /app/dist /usr/share/nginx/html
41
 
42
  # Copy nginx configuration
43
+ COPY client/nginx.conf /etc/nginx/http.d/default.conf
44
+
45
+ # Copy startup script
46
+ COPY startup.sh .
47
+
48
+ # Make startup script executable
49
+ RUN chmod +x startup.sh
50
+
51
+ # Set environment variable for Hugging Face Spaces
52
+ ENV HF_SPACES=true
53
+
54
+ # Create nginx directories with proper permissions
55
+ RUN mkdir -p /var/lib/nginx/tmp/client_body && \
56
+ chmod -R 755 /var/lib/nginx && \
57
+ chown -R nginx:nginx /var/lib/nginx
58
 
59
+ # Expose ports
60
+ EXPOSE 80 3001
61
 
62
+ # Start both nginx and node server
63
+ CMD ["./startup.sh"]
client/startup.sh ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ # Start the Node.js server in the background
4
+ node index.js &
5
+ NODE_PID=$!
6
+
7
+ # Give the server a moment to start
8
+ sleep 3
9
+
10
+ # Start nginx in the foreground
11
+ nginx -g "daemon off;"