Install @media-cluster packages after npm install so they are not wiped.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4e232e8ef6
commit
f6da966a92
1 changed files with 26 additions and 6 deletions
|
|
@ -13,22 +13,26 @@ WORKDIR /app/apps/master-api
|
||||||
RUN pnpm exec prisma generate
|
RUN pnpm exec prisma generate
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
# Assemble a flat runtime directory (avoids broken pnpm symlinks in final image)
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN mkdir -p /out/node_modules/@media-cluster \
|
RUN mkdir -p /out \
|
||||||
&& cp -R apps/master-api/dist /out/dist \
|
&& cp -R apps/master-api/dist /out/dist \
|
||||||
&& cp -R apps/master-api/prisma /out/prisma \
|
&& cp -R apps/master-api/prisma /out/prisma \
|
||||||
&& cp apps/master-api/package.json /out/package.json \
|
&& cp apps/master-api/package.json /out/package.json \
|
||||||
&& cp -R packages/shared-types /out/node_modules/@media-cluster/shared-types \
|
&& mkdir -p /out/local-packages \
|
||||||
&& cp -R packages/protocol /out/node_modules/@media-cluster/protocol
|
&& cp -R packages/shared-types /out/local-packages/shared-types \
|
||||||
|
&& cp -R packages/protocol /out/local-packages/protocol
|
||||||
|
|
||||||
FROM node:20-alpine AS runner
|
FROM node:20-alpine AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
RUN apk add --no-cache openssl wget python3 make g++
|
RUN apk add --no-cache openssl wget python3 make g++
|
||||||
COPY --from=builder /out/ ./
|
|
||||||
|
|
||||||
# Drop workspace: protocol deps; keep prisma CLI for migrate
|
COPY --from=builder /out/dist ./dist
|
||||||
|
COPY --from=builder /out/prisma ./prisma
|
||||||
|
COPY --from=builder /out/package.json ./package.json
|
||||||
|
COPY --from=builder /out/local-packages ./local-packages
|
||||||
|
|
||||||
|
# Remove workspace protocol deps before npm install
|
||||||
RUN node -e "\
|
RUN node -e "\
|
||||||
const fs=require('fs');\
|
const fs=require('fs');\
|
||||||
const p=JSON.parse(fs.readFileSync('package.json','utf8'));\
|
const p=JSON.parse(fs.readFileSync('package.json','utf8'));\
|
||||||
|
|
@ -43,6 +47,22 @@ RUN npm install --omit=dev \
|
||||||
&& npx prisma generate \
|
&& npx prisma generate \
|
||||||
&& apk del python3 make g++
|
&& apk del python3 make g++
|
||||||
|
|
||||||
|
# IMPORTANT: copy workspace packages AFTER npm install (npm wipes node_modules)
|
||||||
|
RUN mkdir -p node_modules/@media-cluster \
|
||||||
|
&& cp -R local-packages/shared-types node_modules/@media-cluster/shared-types \
|
||||||
|
&& cp -R local-packages/protocol node_modules/@media-cluster/protocol \
|
||||||
|
&& node -e "\
|
||||||
|
const fs=require('fs');\
|
||||||
|
const p=JSON.parse(fs.readFileSync('node_modules/@media-cluster/protocol/package.json','utf8'));\
|
||||||
|
p.dependencies={'@media-cluster/shared-types':'1.0.0'};\
|
||||||
|
delete p.devDependencies;\
|
||||||
|
fs.writeFileSync('node_modules/@media-cluster/protocol/package.json', JSON.stringify(p,null,2));\
|
||||||
|
const s=JSON.parse(fs.readFileSync('node_modules/@media-cluster/shared-types/package.json','utf8'));\
|
||||||
|
delete s.devDependencies;\
|
||||||
|
fs.writeFileSync('node_modules/@media-cluster/shared-types/package.json', JSON.stringify(s,null,2));\
|
||||||
|
" \
|
||||||
|
&& node -e "require('@media-cluster/protocol'); require('@media-cluster/shared-types'); console.log('workspace packages ok')"
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=5 \
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=5 \
|
||||||
CMD wget -qO- http://127.0.0.1:3000/health || exit 1
|
CMD wget -qO- http://127.0.0.1:3000/health || exit 1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue