managarten/apps/chat/apps/backend/Dockerfile
Wuesteon 1be3d7a3ae 🐛 fix(docker): add missing workspace dependencies to all Dockerfiles
Ensure all backend Dockerfiles copy and build ALL workspace dependencies
they need. This fixes Docker build failures where packages couldn't find
their @manacore/* dependencies.

**Changes:**

**Picture Backend:**
- Added better-auth-types (with build)
- Added mana-core-nestjs-integration (with build)
- Added shared-nestjs-auth (with build)
- Added shared-storage (with build)

**Chat Backend:**
- Added mana-core-nestjs-integration (with build)

**Calendar, Clock, Todo Backends:**
- Added shared-nestjs-cors (already had other deps)

**Mana Core Auth:**
- Restructured for monorepo workspace support
- Added shared-nestjs-cors

**Key Improvements:**
- All packages in alphabetical order
- Build steps for compiled packages
- Source-only packages (shared-nestjs-cors) skip build
- Proper dependency ordering in build steps

This ensures Docker builds work correctly after the CORS package addition.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-17 18:19:29 +01:00

80 lines
2.2 KiB
Docker

# Build stage
FROM node:20-alpine AS builder
# Install pnpm
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
WORKDIR /app
# Copy root workspace files
COPY pnpm-workspace.yaml ./
COPY package.json ./
COPY pnpm-lock.yaml ./
# Copy shared packages
COPY packages/better-auth-types ./packages/better-auth-types
COPY packages/mana-core-nestjs-integration ./packages/mana-core-nestjs-integration
COPY packages/shared-errors ./packages/shared-errors
COPY packages/shared-nestjs-auth ./packages/shared-nestjs-auth
COPY packages/shared-nestjs-cors ./packages/shared-nestjs-cors
COPY packages/shared-storage ./packages/shared-storage
# Copy chat backend
COPY apps/chat/apps/backend ./apps/chat/apps/backend
# Install dependencies
RUN pnpm install --frozen-lockfile
# Build shared packages first
WORKDIR /app/packages/better-auth-types
RUN pnpm build
WORKDIR /app/packages/mana-core-nestjs-integration
RUN pnpm build
WORKDIR /app/packages/shared-errors
RUN pnpm build
WORKDIR /app/packages/shared-nestjs-auth
RUN pnpm build
WORKDIR /app/packages/shared-storage
RUN pnpm build
# Build the backend
WORKDIR /app/apps/chat/apps/backend
RUN pnpm build
# Production stage
FROM node:20-alpine AS production
# Install pnpm and postgresql-client for health checks
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate \
&& apk add --no-cache postgresql-client
WORKDIR /app
# Copy everything from builder (including node_modules)
COPY --from=builder /app/pnpm-workspace.yaml ./
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-lock.yaml ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/apps/chat/apps/backend ./apps/chat/apps/backend
# Copy entrypoint script
COPY apps/chat/apps/backend/docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
WORKDIR /app/apps/chat/apps/backend
# Expose port
EXPOSE 3002
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3002/api/health || exit 1
# Run entrypoint script
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "dist/main.js"]