fix(admin-service): 修复 Dockerfile 启动脚本生成问题

使用 printf 替代 echo 来创建 start.sh 脚本,确保正确处理换行符,
使数据库迁移能够在容器启动时正确执行。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-20 02:59:53 -08:00
parent 00a239a271
commit 3d93ebe928
1 changed files with 8 additions and 6 deletions

View File

@ -53,12 +53,14 @@ RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
COPY --from=builder /app/dist ./dist
# Create startup script that runs migrations 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 "Starting application..."\n\
exec node dist/main.js\n' > /app/start.sh && chmod +x /app/start.sh
RUN printf '%s\n' \
'#!/bin/sh' \
'set -e' \
'echo "Running database migrations..."' \
'npx prisma migrate deploy || npx prisma db push --accept-data-loss' \
'echo "Starting application..."' \
'exec node dist/main.js' \
> /app/start.sh && chmod +x /app/start.sh
# Create non-root user
RUN groupadd -g 1001 nodejs && \