fix: referral-service启动时自动执行seed
- 添加ts-node依赖用于执行seed.ts - 在start.sh中添加prisma db seed命令 - 与identity-service保持一致 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f98f7b2d39
commit
17121da422
|
|
@ -41,9 +41,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install production dependencies only
|
||||
# Install production dependencies + ts-node for seed
|
||||
COPY package*.json ./
|
||||
RUN npm ci --only=production
|
||||
COPY tsconfig*.json ./
|
||||
RUN npm ci --only=production && npm install ts-node typescript @types/node --save-dev
|
||||
|
||||
# Copy Prisma schema and generate client (dummy DATABASE_URL for build time only)
|
||||
COPY prisma ./prisma/
|
||||
|
|
@ -52,11 +53,13 @@ RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
|
|||
# Copy built files
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Create startup script that runs migrations before starting the app
|
||||
# Create startup script that runs migrations and seed before starting the app
|
||||
RUN echo '#!/bin/sh\n\
|
||||
set -e\n\
|
||||
echo "Running database migrations..."\n\
|
||||
npx prisma migrate deploy || npx prisma db push --accept-data-loss\n\
|
||||
echo "Running database seed..."\n\
|
||||
npx prisma db seed || echo "Seed completed (or already seeded)"\n\
|
||||
echo "Starting application..."\n\
|
||||
exec node dist/main.js\n' > /app/start.sh && chmod +x /app/start.sh
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue