Add complete dockerized amigos app with React frontend and MongoDB backend
This commit is contained in:
40
Dockerfile
Normal file
40
Dockerfile
Normal file
@@ -0,0 +1,40 @@
|
||||
# Build stage for React app
|
||||
FROM node:18-alpine AS frontend-build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy frontend package files
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Copy frontend source
|
||||
COPY index.html vite.config.js ./
|
||||
COPY src ./src
|
||||
|
||||
# Build React app
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:18-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy backend files
|
||||
COPY backend/package*.json ./backend/
|
||||
WORKDIR /app/backend
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy backend source files
|
||||
COPY backend/server-prod.js ./
|
||||
|
||||
# Copy built React app from build stage
|
||||
COPY --from=frontend-build /app/dist /app/dist
|
||||
|
||||
# Go back to app directory
|
||||
WORKDIR /app
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3001
|
||||
|
||||
# Start the backend server
|
||||
CMD ["node", "backend/server-prod.js"]
|
||||
Reference in New Issue
Block a user