56 lines
1.4 KiB
Docker
56 lines
1.4 KiB
Docker
# apps/frontend/Dockerfile
|
|
FROM node:24-alpine AS base
|
|
RUN npm install -g pnpm@8
|
|
|
|
FROM base AS dependencies
|
|
WORKDIR /app
|
|
|
|
# Copy workspace configuration
|
|
COPY pnpm-workspace.yaml package.json ./
|
|
COPY apps/frontend/package.json ./apps/frontend/
|
|
COPY packages/shared/package.json ./packages/shared/
|
|
|
|
# Install dependencies
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
FROM base AS build
|
|
WORKDIR /app
|
|
COPY --from=dependencies /app/node_modules ./node_modules
|
|
COPY --from=dependencies /app/apps/frontend/node_modules ./apps/frontend/node_modules
|
|
COPY --from=dependencies /app/packages/shared/node_modules ./packages/shared/node_modules
|
|
|
|
# Copy source code
|
|
COPY packages/shared ./packages/shared
|
|
COPY apps/frontend ./apps/frontend
|
|
|
|
# Build shared packages first
|
|
RUN pnpm --filter @dreamchat/shared build
|
|
|
|
# Build frontend
|
|
RUN pnpm --filter @dreamchat/frontend build
|
|
|
|
# Production stage - using serve for static files
|
|
# External reverse proxy (nginx/traefik/etc.) expected
|
|
FROM node:24-alpine AS production
|
|
WORKDIR /app
|
|
|
|
# Install serve
|
|
RUN npm install -g serve
|
|
|
|
# Copy built assets
|
|
COPY --from=build /app/apps/frontend/dist ./dist
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S nodejs
|
|
RUN adduser -S nodejs -u 1001
|
|
USER nodejs
|
|
|
|
EXPOSE 3000
|
|
|
|
# Serve static files
|
|
# Note: External reverse proxy should handle:
|
|
# - SSL/TLS termination
|
|
# - Path routing (/api -> backend, / -> frontend)
|
|
# - WebSocket proxying
|
|
CMD ["serve", "-s", "dist", "-l", "3000"]
|