abubasith86 commited on
Commit
877a9d0
·
1 Parent(s): d0d946a
Files changed (1) hide show
  1. Dockerfile +42 -9
Dockerfile CHANGED
@@ -1,23 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
- RUN ls
 
13
 
14
- # Install npm dependencies
15
- RUN npm install
16
 
17
- RUN npm ci
 
 
 
 
 
18
 
19
- # Expose the port your application runs on
20
  EXPOSE 5000
21
 
22
- # Start the application
23
- CMD ["npm", "start"]
 
 
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
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
+ # RUN if [ -f "Dockerfile" ]; then echo "Found Dockerfile in repo"; else echo "No Dockerfile found" && exit 1; fi
13
+
14
+ # # Install npm dependencies
15
+ # RUN npm install
16
+
17
+ # RUN npm ci
18
+
19
+ # # Expose the port your application runs on
20
+ # EXPOSE 5000
21
+
22
+ # # Start the application
23
+ # CMD ["npm", "start"]
24
+
25
+
26
+ # Base image
27
  FROM node:23.7.0 as builder
28
 
29
+ # Install required packages
30
  RUN apt-get update && apt-get install -y git
31
 
32
+ # Clone the repository (always fetch the latest code)
33
  RUN rm -rf /usr/src/app && git clone https://github.com/abubasith456/Node-WLA.git /usr/src/app
34
 
35
  # Set the working directory
36
  WORKDIR /usr/src/app
37
 
38
+ # Check if the repo contains a Dockerfile
39
+ RUN if [ -f "Dockerfile" ]; then echo "Found Dockerfile in repo"; else echo "No Dockerfile found" && exit 1; fi
40
 
41
+ # Copy the Dockerfile from the cloned repo
42
+ COPY --from=builder /usr/src/app/Dockerfile /usr/src/app/
43
 
44
+ # Switch to the repository's Dockerfile to build the final image
45
+ WORKDIR /usr/src/app
46
+ RUN chmod +x Dockerfile
47
+
48
+ # Build the repo's Docker image
49
+ RUN /usr/bin/docker build -t my-app .
50
 
51
+ # Expose the correct port
52
  EXPOSE 5000
53
 
54
+ # Run the application inside the built container
55
+ CMD ["/usr/bin/docker", "run", "-p", "5000:5000", "my-app"]
56
+