Spaces:
Sleeping
Sleeping
abubasith86
commited on
Commit
·
73046d5
1
Parent(s):
58b31c8
Check
Browse files- Dockerfile +52 -27
Dockerfile
CHANGED
@@ -1,42 +1,67 @@
|
|
1 |
-
#
|
2 |
-
FROM node:23.7.0 as builder
|
3 |
|
4 |
-
# Install git
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
RUN apt-get update && apt-get install -y git
|
6 |
|
7 |
-
# Clone the GitHub repository
|
8 |
-
RUN git clone https://github.com/abubasith456/Node-WLA.git /usr/src/app
|
9 |
|
10 |
# Set working directory
|
11 |
WORKDIR /usr/src/app
|
12 |
|
13 |
-
#
|
14 |
-
RUN
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
|
19 |
-
#
|
20 |
-
RUN
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
-
|
25 |
-
# Remove default Nginx config
|
26 |
-
RUN rm /etc/nginx/conf.d/default.conf
|
27 |
-
|
28 |
-
# Copy custom Nginx config from main project
|
29 |
-
COPY --from=builder /usr/src/app/nginx.conf /etc/nginx/conf.d/default.conf
|
30 |
|
31 |
-
#
|
32 |
-
|
33 |
|
34 |
-
#
|
35 |
-
|
36 |
|
37 |
-
#
|
38 |
-
|
39 |
|
40 |
-
#
|
41 |
-
|
42 |
|
|
|
|
|
|
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 |
+
# Copy Nginx configuration file
|
61 |
+
COPY nginx.conf /etc/nginx/nginx.conf
|
62 |
|
63 |
+
# Expose ports
|
64 |
+
EXPOSE 80 443 5000
|
65 |
|
66 |
+
# Start Nginx in the foreground
|
67 |
+
CMD ["nginx", "-g", "daemon off;"]
|