This commit is contained in:
Luke Gustafson
2024-11-27 00:13:26 +00:00
parent 54510d0fbf
commit a9e652b1c8
13 changed files with 74 additions and 17 deletions

View File

@@ -2,20 +2,16 @@
FROM node:18-slim AS frontend-build
WORKDIR /app
# Copy all project files into the image
COPY . .
# Install dependencies
# Copy frontend files
COPY frontend/package*.json ./frontend/
WORKDIR /app/frontend
RUN npm install
# Build the application
COPY frontend/ .
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
COPY --from=frontend-build /app/dist /usr/share/nginx/html
COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
@@ -23,13 +19,11 @@ CMD ["nginx", "-g", "daemon off;"]
FROM node:18-slim AS backend
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
# Copy backend files
COPY backend/package*.json ./
RUN npm install
COPY backend/ .
# Copy server.js from its new location
COPY /app/src/components/server.js /app
# Run backend
EXPOSE 3001
CMD ["node", "/app/src/components/server.js"]