Spaces:
Sleeping
Sleeping
# FROM node:23.7.0 as builder | |
# # Install git | |
# RUN apt-get update && apt-get install -y git | |
# # Clone the GitHub repository (if not already cloned) | |
# RUN rm -rf /usr/src/app && git clone https://github.com/abubasith456/Node-WLA.git /usr/src/app | |
# # Set the working directory | |
# WORKDIR /usr/src/app | |
# # Change ownership of the directory to the current user (node) | |
# RUN chown -R node:node /usr/src/app | |
# # Mark the repository directory as safe | |
# USER node | |
# RUN git config --global --add safe.directory /usr/src/app | |
# # Install npm dependencies | |
# RUN npm install | |
# # Expose the port your application runs on | |
# EXPOSE 5000 | |
# # Ensure that the latest code is pulled before starting the app | |
# CMD git pull origin main && npm install && npm start | |
# First stage: Node.js application build | |
FROM node:23.7.0 AS builder | |
# Install git | |
RUN apt-get update && apt-get install -y git | |
# Clone the GitHub repository | |
RUN rm -rf /usr/src/app && git clone https://github.com/abubasith456/Node-WLA.git /usr/src/app | |
# Set working directory | |
WORKDIR /usr/src/app | |
# Change ownership of the directory to node user | |
RUN chown -R node:node /usr/src/app | |
# Switch to node user | |
USER node | |
# Mark the repository directory as safe | |
RUN git config --global --add safe.directory /usr/src/app | |
# Install npm dependencies | |
RUN npm install | |
# Second stage: Nginx setup | |
FROM nginx:latest | |
# Copy built Node.js app from builder stage | |
COPY --from=builder /usr/src/app /usr/src/app | |
# Copy Nginx configuration file | |
COPY ./nginx.conf /etc/nginx/nginx.conf | |
# Expose ports | |
EXPOSE 80 443 5000 | |
# Start Nginx in the foreground | |
CMD ["nginx", "-g", "daemon off;"] | |