abubasith86 commited on
Commit
628ea2d
·
1 Parent(s): 344e17c
Files changed (1) hide show
  1. Dockerfile +9 -52
Dockerfile CHANGED
@@ -1,69 +1,26 @@
1
- # FROM node:23.7.0 as builder
2
-
3
- # # Install git
4
- # RUN apt-get update && apt-get install -y git
5
-
6
- # # Clone the GitHub repository (if not already cloned)
7
- # RUN rm -rf /usr/src/app && git clone https://github.com/abubasith456/Node-WLA.git /usr/src/app
8
-
9
- # # Set the working directory
10
- # WORKDIR /usr/src/app
11
-
12
- # # Change ownership of the directory to the current user (node)
13
- # RUN chown -R node:node /usr/src/app
14
-
15
- # # Mark the repository directory as safe
16
- # USER node
17
- # RUN git config --global --add safe.directory /usr/src/app
18
-
19
- # # Install npm dependencies
20
- # RUN npm install
21
-
22
- # # Expose the port your application runs on
23
- # EXPOSE 5000
24
-
25
- # # Ensure that the latest code is pulled before starting the app
26
- # CMD git pull origin main && npm install && npm start
27
-
28
-
29
-
30
- # First stage: Node.js application build
31
- FROM node:23.7.0 AS builder
32
 
33
  # Install git
34
  RUN apt-get update && apt-get install -y git
35
 
36
- # Clone the GitHub repository
37
  RUN rm -rf /usr/src/app && git clone https://github.com/abubasith456/Node-WLA.git /usr/src/app
38
 
39
- # Set working directory
40
  WORKDIR /usr/src/app
41
 
42
- # Change ownership of the directory to node user
43
  RUN chown -R node:node /usr/src/app
44
 
45
- # Switch to node user
46
- USER node
47
-
48
  # Mark the repository directory as safe
 
49
  RUN git config --global --add safe.directory /usr/src/app
50
 
51
  # Install npm dependencies
52
  RUN npm install
53
 
54
- # Second stage: Nginx setup
55
- FROM nginx:latest
56
-
57
- # Copy built Node.js app from builder stage
58
- COPY --from=builder /usr/src/app /usr/src/app
59
-
60
- RUN ls -l nginx.conf
61
-
62
- # Copy Nginx configuration file
63
- COPY ./nginx.conf /etc/nginx/nginx.conf
64
-
65
- # Expose ports
66
- EXPOSE 80 443 5000
67
 
68
- # Start Nginx in the foreground
69
- CMD ["nginx", "-g", "daemon off;"]
 
1
+ FROM node:23.7.0 as builder
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  # Install git
4
  RUN apt-get update && apt-get install -y git
5
 
6
+ # Clone the GitHub repository (if not already cloned)
7
  RUN rm -rf /usr/src/app && git clone https://github.com/abubasith456/Node-WLA.git /usr/src/app
8
 
9
+ # Set the working directory
10
  WORKDIR /usr/src/app
11
 
12
+ # Change ownership of the directory to the current user (node)
13
  RUN chown -R node:node /usr/src/app
14
 
 
 
 
15
  # Mark the repository directory as safe
16
+ USER node
17
  RUN git config --global --add safe.directory /usr/src/app
18
 
19
  # Install npm dependencies
20
  RUN npm install
21
 
22
+ # Expose the port your application runs on
23
+ EXPOSE 5000
 
 
 
 
 
 
 
 
 
 
 
24
 
25
+ # Ensure that the latest code is pulled before starting the app
26
+ CMD git pull origin main && npm install && npm start