fix(gateway): include workspace packages in Docker build
Copy @multica/sdk and @multica/store workspace packages into both builder and production stages. Build them with tsc in the builder stage, then patch their package.json exports to point from ./src/*.ts to ./dist/*.js for Node.js runtime compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
31f38bb0ec
commit
01f64ff1ec
1 changed files with 26 additions and 0 deletions
|
|
@ -8,10 +8,17 @@ WORKDIR /app
|
|||
|
||||
# Copy package files (pnpm-workspace.yaml needed for catalog resolution)
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY packages/sdk/package.json ./packages/sdk/
|
||||
COPY packages/store/package.json ./packages/store/
|
||||
|
||||
# Install all dependencies (including devDependencies for build)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy workspace packages and build them
|
||||
COPY packages/sdk/ ./packages/sdk/
|
||||
COPY packages/store/ ./packages/store/
|
||||
RUN pnpm --filter @multica/sdk build && cd packages/store && ../../node_modules/.bin/tsc
|
||||
|
||||
# Copy source code
|
||||
COPY tsconfig.json ./
|
||||
COPY src ./src
|
||||
|
|
@ -29,10 +36,29 @@ WORKDIR /app
|
|||
|
||||
# Copy package files (pnpm-workspace.yaml needed for catalog resolution)
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY packages/sdk/package.json ./packages/sdk/
|
||||
COPY packages/store/package.json ./packages/store/
|
||||
|
||||
# Install production dependencies only
|
||||
RUN pnpm install --frozen-lockfile --prod
|
||||
|
||||
# Copy built workspace packages and patch exports to point to compiled JS
|
||||
COPY --from=builder /app/packages/sdk/dist ./packages/sdk/dist
|
||||
COPY --from=builder /app/packages/store/dist ./packages/store/dist
|
||||
RUN node -e " \
|
||||
const fs = require('fs'); \
|
||||
['packages/sdk/package.json', 'packages/store/package.json'].forEach(p => { \
|
||||
const pkg = JSON.parse(fs.readFileSync(p, 'utf8')); \
|
||||
if (pkg.exports) { \
|
||||
for (const [key, val] of Object.entries(pkg.exports)) { \
|
||||
if (typeof val === 'string') { \
|
||||
pkg.exports[key] = val.replace('./src/', './dist/').replace('.ts', '.js'); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
fs.writeFileSync(p, JSON.stringify(pkg, null, 2)); \
|
||||
});"
|
||||
|
||||
# Copy built files from builder stage
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue