From 3d93ebe92867cf78de36cebe9f37191fd34e5a3b Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 20 Dec 2025 02:59:53 -0800 Subject: [PATCH] =?UTF-8?q?fix(admin-service):=20=E4=BF=AE=E5=A4=8D=20Dock?= =?UTF-8?q?erfile=20=E5=90=AF=E5=8A=A8=E8=84=9A=E6=9C=AC=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用 printf 替代 echo 来创建 start.sh 脚本,确保正确处理换行符, 使数据库迁移能够在容器启动时正确执行。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- backend/services/admin-service/Dockerfile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/services/admin-service/Dockerfile b/backend/services/admin-service/Dockerfile index a3c0bc12..17a96bf6 100644 --- a/backend/services/admin-service/Dockerfile +++ b/backend/services/admin-service/Dockerfile @@ -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 && \