45 lines
776 B
Docker
45 lines
776 B
Docker
# Build stage
|
|
FROM node:18-alpine AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
COPY frontend/package*.json ./frontend/
|
|
|
|
# Install dependencies
|
|
RUN npm install
|
|
RUN cd frontend && npm install
|
|
|
|
# Copy source files
|
|
COPY . .
|
|
COPY frontend ./frontend
|
|
|
|
# Build frontend
|
|
RUN cd frontend && npm run build
|
|
|
|
# Build backend
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:18-alpine
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install production dependencies only
|
|
RUN npm install --production
|
|
|
|
# Copy built files from builder stage
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/frontend/build ./frontend/build
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Start the application
|
|
CMD ["npm", "start"] |