37 lines
725 B
Docker
37 lines
725 B
Docker
# chat/Dockerfile
|
|
# Stage 1: build frontend
|
|
FROM node:20-alpine AS build
|
|
|
|
WORKDIR /app
|
|
|
|
# copy frontend
|
|
COPY chat-frontend/ ./chat-frontend/
|
|
|
|
WORKDIR /app/chat-frontend
|
|
RUN npm install
|
|
RUN npm run build
|
|
|
|
# Stage 2: backend + serve frontend
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy built frontend
|
|
COPY --from=build /app/chat-frontend/dist ./frontend
|
|
|
|
# Copy backend
|
|
COPY chat-backend/package*.json ./chat-backend/
|
|
COPY chat-backend/server.js ./chat-backend/
|
|
|
|
WORKDIR /app/chat-backend
|
|
RUN npm install
|
|
|
|
# Expose backend WebSocket port and static frontend
|
|
EXPOSE 3000
|
|
|
|
# Start both backend and frontend
|
|
# Using simple Node backend and serve frontend via a tiny static server
|
|
RUN npm install -g serve
|
|
|
|
CMD ["node", "server.js"]
|