gaialive commited on
Commit
bea7063
·
verified ·
1 Parent(s): d94489d

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -44
  2. start.sh +12 -0
Dockerfile CHANGED
@@ -1,45 +1,4 @@
1
- #Multi-stage build for frontend
2
- FROM node:18-alpine as frontend-build
3
-
4
- # Set the working directory
5
- WORKDIR /app
6
-
7
- # Copy frontend files
8
- COPY frontend/package*.json ./
9
- RUN npm install
10
- COPY frontend/ ./
11
- RUN npm run build
12
-
13
- # Backend build
14
- FROM node:18-alpineas backend-build
15
- WORKDIR /app
16
- COPY backend/package*.json ./
17
- RUN npm install
18
- COPY backend/ ./
19
-
20
- # Final stage
21
- FROM node:18-alpine
22
-
23
- # Install nginx
24
- RUN apk add --no-cache nginx
25
-
26
- # Copy frontend build
27
- COPY --from=frontend-build /app/dist /var/www/html
28
-
29
- # Copy nginx config
30
- COPY nginx.conf /etc/nginx/nginx.conf
31
-
32
- # Setup backend
33
- WORKDIR /app
34
- COPY --from=backend-build /app ./
35
-
36
- # Expose ports
37
- EXPOSE 80 3000
38
-
39
- # Start both services
40
- CMD nginx && npm start
41
-
42
- # Useasingle Node.js base image
43
  FROM node:18-bullseye
44
 
45
  # Create app directory
@@ -51,7 +10,7 @@ COPY backend/package*.json ./backend/
51
 
52
  # Install dependencies for both frontend and backend
53
  RUN cd frontend && npm install
54
- RUN cdbackend && npm install
55
 
56
  # Copy the rest of the application code
57
  COPY . .
@@ -63,4 +22,4 @@ RUN chmod +x start.sh
63
  EXPOSE 5173 3000
64
 
65
  # Start both services
66
- CMD ["./start.sh"]
 
1
+ # Use a single Node.js base image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  FROM node:18-bullseye
3
 
4
  # Create app directory
 
10
 
11
  # Install dependencies for both frontend and backend
12
  RUN cd frontend && npm install
13
+ RUN cd backend && npm install
14
 
15
  # Copy the rest of the application code
16
  COPY . .
 
22
  EXPOSE 5173 3000
23
 
24
  # Start both services
25
+ CMD ["./start.sh"]
start.sh ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Start the backend server in the background
4
+ cd backend
5
+ npm start &
6
+
7
+ # Wait a moment for the backend to start
8
+ sleep 5
9
+
10
+ # Start the frontend development server
11
+ cd ../frontend
12
+ npm run dev