# UI Dockerfile - Multi-stage build for ThoughtMCP UI
#
# Development: docker build --target dev -t thoughtmcp-ui:dev .
# Production: docker build -t thoughtmcp-ui .
#
# Usage with docker-compose:
# Dev: docker compose -f docker-compose.dev.yml --profile ui up -d
# Prod: docker compose -f docker-compose.prod.yml --profile ui up -d
# ============================================================================
# Stage 1: Dependencies
# ============================================================================
FROM node:20-alpine AS deps
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci
# ============================================================================
# Stage 2: Development
# ============================================================================
FROM node:20-alpine AS dev
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
# Copy source files
COPY . .
# Expose Vite dev server port
EXPOSE 5173
# Start Vite dev server with host binding for Docker
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
# ============================================================================
# Stage 3: Build
# ============================================================================
FROM node:20-alpine AS builder
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
# Copy source files
COPY . .
# Build argument for API URL
ARG VITE_API_URL=http://localhost:3000
ENV VITE_API_URL=$VITE_API_URL
# Build the application
RUN npm run build
# ============================================================================
# Stage 4: Production
# ============================================================================
FROM nginx:alpine AS production
# Copy custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built assets from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]