gaialive commited on
Commit
4a01764
·
verified ·
1 Parent(s): 9070bff

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +15 -17
  2. startup.sh +15 -2
Dockerfile CHANGED
@@ -17,20 +17,6 @@ COPY client/ ./
17
  # Build client
18
  RUN npm run build
19
 
20
- # Build the server
21
- FROM node:18-alpine AS server-builder
22
-
23
- WORKDIR /app
24
-
25
- # Copy server package files
26
- COPY server/package*.json ./
27
-
28
- # Install server dependencies
29
- RUN npm install --only=production
30
-
31
- # Copy server source
32
- COPY server/ ./server/
33
-
34
  # Production image
35
  FROM node:18-alpine
36
 
@@ -40,10 +26,17 @@ RUN apk add --no-cache nginx
40
  # Create app directory
41
  WORKDIR /app
42
 
43
- # Copy server files
44
- COPY --from=server-builder /app/server ./
 
 
 
 
 
 
45
 
46
- # Copy client build to nginx
 
47
  COPY --from=client-builder /app/dist /usr/share/nginx/html
48
 
49
  # Copy nginx configuration
@@ -55,6 +48,11 @@ COPY startup.sh .
55
  # Make startup script executable
56
  RUN chmod +x startup.sh
57
 
 
 
 
 
 
58
  # Expose ports
59
  EXPOSE 80 3001
60
 
 
17
  # Build client
18
  RUN npm run build
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # Production image
21
  FROM node:18-alpine
22
 
 
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
 
48
  # Make startup script executable
49
  RUN chmod +x startup.sh
50
 
51
+ # Create nginx directories with proper permissions
52
+ RUN mkdir -p /var/lib/nginx/tmp/client_body && \
53
+ chmod -R 755 /var/lib/nginx && \
54
+ chown -R nginx:nginx /var/lib/nginx
55
+
56
  # Expose ports
57
  EXPOSE 80 3001
58
 
startup.sh CHANGED
@@ -1,10 +1,23 @@
1
  #!/bin/sh
2
 
 
 
 
3
  # Start the Node.js server in the background
4
- node index.js &
 
5
 
6
  # Give the server a moment to start
7
- sleep 3
 
 
 
 
 
 
 
 
8
 
9
  # Start nginx in the foreground
 
10
  nginx -g "daemon off;"
 
1
  #!/bin/sh
2
 
3
+ # Create log directory if it doesn't exist
4
+ mkdir -p /var/log
5
+
6
  # Start the Node.js server in the background
7
+ node index.js > /var/log/node-server.log 2>&1 &
8
+ NODE_PID=$!
9
 
10
  # Give the server a moment to start
11
+ sleep 5
12
+
13
+ # Check if the server is running
14
+ if ! kill -0 $NODE_PID 2>/dev/null; then
15
+ echo "Node.js server failed to start. Check logs in /var/log/node-server.log"
16
+ exit 1
17
+ fi
18
+
19
+ echo "Node.js server started with PID $NODE_PID"
20
 
21
  # Start nginx in the foreground
22
+ echo "Starting nginx..."
23
  nginx -g "daemon off;"