mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 22:21:10 +02:00
🐛 fix(docker): fix manadeck backend Dockerfile to use pnpm
Changes: - Replace npm with pnpm for workspace dependency support - Copy workspace files (pnpm-workspace.yaml, package.json, pnpm-lock.yaml) - Copy and build shared package dependencies: - @manacore/shared-errors - @manacore/manadeck-database - @mana-core/nestjs-integration - Use pnpm install --frozen-lockfile - Update base image to node:20-alpine - Use dumb-init for proper signal handling This fixes the "Unsupported URL Type 'workspace:'" error that was preventing Docker builds. The new approach matches the pattern used by the chat backend Dockerfile. Fixes build error in CI/CD pipeline. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
aca6cdbaa5
commit
a87e1389cf
1 changed files with 43 additions and 36 deletions
|
|
@ -1,34 +1,47 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
# Build stage
|
||||
FROM node:18-alpine AS builder
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
# Install pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache python3 make g++
|
||||
# Copy root workspace files
|
||||
COPY pnpm-workspace.yaml ./
|
||||
COPY package.json ./
|
||||
COPY pnpm-lock.yaml ./
|
||||
|
||||
# Copy package.json
|
||||
COPY apps/manadeck/apps/backend/package.json ./
|
||||
# Copy shared packages
|
||||
COPY packages/shared-errors ./packages/shared-errors
|
||||
COPY packages/manadeck-database ./packages/manadeck-database
|
||||
COPY packages/mana-core-nestjs-integration ./packages/mana-core-nestjs-integration
|
||||
|
||||
# Copy manadeck backend
|
||||
COPY apps/manadeck/apps/backend ./apps/manadeck/apps/backend
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install --legacy-peer-deps
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy source code
|
||||
COPY apps/manadeck/apps/backend/ ./
|
||||
# Build shared packages first
|
||||
WORKDIR /app/packages/shared-errors
|
||||
RUN pnpm build
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
WORKDIR /app/packages/manadeck-database
|
||||
RUN pnpm build
|
||||
|
||||
# Debug: List the contents to verify build output
|
||||
RUN echo "=== Listing dist contents ===" && \
|
||||
ls -la dist/ || echo "No dist folder found" && \
|
||||
echo "=== Build complete ==="
|
||||
WORKDIR /app/packages/mana-core-nestjs-integration
|
||||
RUN pnpm build
|
||||
|
||||
# Build the backend
|
||||
WORKDIR /app/apps/manadeck/apps/backend
|
||||
RUN pnpm build
|
||||
|
||||
# Production stage
|
||||
FROM node:18-alpine
|
||||
FROM node:20-alpine AS production
|
||||
|
||||
# Install dumb-init for proper signal handling
|
||||
RUN apk add --no-cache dumb-init
|
||||
# Install pnpm and dumb-init
|
||||
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate \
|
||||
&& apk add --no-cache dumb-init
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
|
|
@ -36,22 +49,13 @@ RUN addgroup -g 1001 -S nodejs && \
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the dist folder
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Copy package.json for metadata
|
||||
# Copy everything from builder (including node_modules)
|
||||
COPY --from=builder /app/pnpm-workspace.yaml ./
|
||||
COPY --from=builder /app/package.json ./
|
||||
|
||||
# Copy node_modules
|
||||
COPY --from=builder /app/pnpm-lock.yaml ./
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
|
||||
# Debug in production to verify file structure
|
||||
RUN echo "=== Production stage file check ===" && \
|
||||
ls -la /app/ && \
|
||||
echo "=== Checking dist folder ===" && \
|
||||
ls -la /app/dist/ || echo "No dist folder" && \
|
||||
echo "=== Looking for main.js ===" && \
|
||||
find /app -name "main.js" -type f 2>/dev/null || echo "main.js not found"
|
||||
COPY --from=builder /app/packages ./packages
|
||||
COPY --from=builder /app/apps/manadeck/apps/backend ./apps/manadeck/apps/backend
|
||||
|
||||
# Change ownership to nodejs user
|
||||
RUN chown -R nodejs:nodejs /app
|
||||
|
|
@ -59,18 +63,21 @@ RUN chown -R nodejs:nodejs /app
|
|||
# Switch to non-root user
|
||||
USER nodejs
|
||||
|
||||
# Expose the port (Cloud Run will set PORT env var)
|
||||
EXPOSE 8080
|
||||
WORKDIR /app/apps/manadeck/apps/backend
|
||||
|
||||
# Expose the port
|
||||
ARG PORT=3003
|
||||
EXPOSE ${PORT}
|
||||
|
||||
# Set environment to production
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD node -e "require('http').get('http://localhost:' + (process.env.PORT || 8080) + '/health', (r) => {r.statusCode === 200 ? process.exit(0) : process.exit(1)})" || exit 1
|
||||
CMD node -e "require('http').get('http://localhost:' + (process.env.PORT || 3003) + '/api/health', (r) => {r.statusCode === 200 ? process.exit(0) : process.exit(1)})" || exit 1
|
||||
|
||||
# Use dumb-init to handle signals properly
|
||||
ENTRYPOINT ["dumb-init", "--"]
|
||||
|
||||
# Start the application
|
||||
CMD ["node", "dist/main"]
|
||||
CMD ["node", "dist/main.js"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue