# lantern-mcp — streamable-http transport image.
#
# Deploys the shim as a long-running HTTP service for MCP gateways (MCPJungle,
# LibreChat) that consume MCP servers over streamable-http instead of stdio.
# stdio mode (Claude Code/Desktop) is unaffected: it uses the .mcpb bundle or a
# bare `node`, not this image.
#
# Build context is this directory (clients/lantern-mcp). docs/openapi.yaml lives
# two levels up and is OUTSIDE the context, so the offline spec is NOT baked in.
# At runtime LANTERN_URL must point at a reachable lantern-api so the live
# /openapi.json is fetched at startup — the normal shape for a gateway deploy,
# where the shim and lantern-api run in the same network. (If you need an
# offline-capable image, set LANTERN_OPENAPI_FILE to a spec you mount in.)

FROM --platform=$BUILDPLATFORM node:20-slim

ENV NODE_ENV=production \
    MCP_TRANSPORT=http \
    SHIM_HOST=0.0.0.0 \
    SHIM_PORT=8768

WORKDIR /app

# Install deps first for layer caching. Lockfile is committed; npm ci fails fast
# if it drifts from package.json.
COPY package.json package-lock.json ./
RUN npm ci --omit=dev

COPY server/ ./server/
COPY cli.js overlay.json manifest.json ./

# Drop privileges — the image never needs root.
USER node

EXPOSE 8768

CMD ["node", "server/index.js"]
