Files
rsvp-manager/Dockerfile

49 lines
950 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/
COPY backend/package*.json ./backend/
# Install dependencies
RUN cd backend && npm install && \
cd ../frontend && npm install
# Copy source files
COPY . .
# Build frontend
RUN cd frontend && npm run build
# Build backend
RUN cd backend && npm run build
# Create database file
RUN touch database.sqlite
# Production stage
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package files
COPY backend/package*.json ./
# Install production dependencies only
RUN npm install --production
# Copy built files from builder stage
COPY --from=builder /app/backend/dist ./dist
COPY --from=builder /app/frontend/build ./frontend/build
COPY --from=builder /app/database.sqlite ./database.sqlite
# Expose port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]