75 lines
1.7 KiB
Plaintext
75 lines
1.7 KiB
Plaintext
<<<<<<< HEAD
|
|
# Stage 1: Build the React app (Frontend)
|
|
FROM node:18-slim AS frontend-build
|
|
WORKDIR /app
|
|
# Copy all project files into the image
|
|
COPY . .
|
|
# Install dependencies
|
|
RUN npm install
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Stage 2: Setup Nginx to serve the React App
|
|
FROM nginx:alpine AS frontend-server
|
|
# Copy built files from builder stage to Nginx's serving directory
|
|
COPY --from=frontend-build /app/dist /usr/share/nginx/html
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|
|
|
|
# Stage 3: Setup the Backend
|
|
FROM node:18-slim AS backend
|
|
WORKDIR /app
|
|
# Copy package.json and package-lock.json
|
|
COPY package*.json ./
|
|
# Install dependencies
|
|
RUN npm install
|
|
# Copy server.js from its new location
|
|
COPY src/components/server.js /app/server.js
|
|
EXPOSE 3001
|
|
# Start the backend server
|
|
CMD ["node", "server.js"]
|
|
=======
|
|
# Stage 1: Build React frontend
|
|
FROM node:18-slim as build
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy project files
|
|
COPY . .
|
|
|
|
# Install dependencies and build the frontend
|
|
RUN npm install
|
|
RUN npm run build
|
|
|
|
# Stage 2: Backend + Nginx setup
|
|
FROM node:18-slim
|
|
|
|
# Set working directory for the backend
|
|
WORKDIR /app
|
|
|
|
# Copy backend files and entrypoint script
|
|
COPY . .
|
|
COPY entrypoint.sh /usr/local/bin/
|
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
|
|
|
# Install backend dependencies
|
|
RUN npm install
|
|
|
|
# Copy the React frontend build into a directory for Nginx
|
|
RUN mkdir -p /usr/share/nginx/html
|
|
COPY --from=build dist /usr/share/nginx/html
|
|
|
|
# Install Nginx
|
|
RUN apt-get update && apt-get install -y nginx && apt-get clean
|
|
|
|
# Copy Nginx configuration
|
|
COPY /docker/nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Expose the ports
|
|
EXPOSE 80 3001
|
|
|
|
# Start both the backend and Nginx
|
|
CMD ["/usr/local/bin/entrypoint.sh"]
|
|
>>>>>>> fc03385d60aedd35d147f7af3ce97533fa67a8d7
|