# Stage 1: The "Builder" Stage - Build the Node.js application FROM node:20-slim AS builder # Install git and ca-certificates to clone the repository securely RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates && rm -rf /var/lib/apt/lists/* # Set the working directory for cloning WORKDIR /app # Clone the notion-mcp-server repository RUN git clone --branch fix-deployment-error https://github.com/JsonLord/notion-mcp-server.git notion-mcp-server # Set the working directory for the Node.js project WORKDIR /app/notion-mcp-server # Use 'npm ci' for a clean, reliable installation of all dependencies RUN npm ci # Run the build script RUN npm run build # ==================== DEBUGGING STEP 1 ==================== # List the contents of the current directory to verify that the 'dist' # directory was created by the build command. RUN echo "--- Contents of /app/notion-mcp-server in builder stage (after build):" && ls -laR . # ========================================================== # Stage 2: The "Final" Stage - Create the Python application image FROM python:3.9-slim # Install nodejs, npm, and ca-certificates in the final image # This is needed because the Python app runs the Node.js server as a subprocess RUN apt-get update && apt-get install -y --no-install-recommends nodejs npm ca-certificates && rm -rf /var/lib/apt/lists/* # Set the working directory for the Python application WORKDIR /app # Copy Python requirements and install them COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt # Copy the app.py file COPY app.py ./ # Crucially, copy the entire built notion-mcp-server directory from the "builder" stage COPY --from=builder /app/notion-mcp-server /app/notion-mcp-server # ==================== DEBUGGING STEP 2 ==================== # List the contents of the copied directory to verify that the 'dist' # directory was successfully brought into the final image. RUN echo "--- Contents of /app/notion-mcp-server in final stage (after copy):" && ls -laR /app/notion-mcp-server # ========================================================== # Expose the port EXPOSE 7860 # Set the final CMD to run uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]