fix: Add entrypoint script to initialize database on container start

This commit is contained in:
2026-03-23 23:53:18 -03:00
parent 9847b4c5cc
commit 1916bc33e4
2 changed files with 14 additions and 0 deletions

View File

@@ -49,6 +49,8 @@ COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/prisma/schema.prisma /app/schema.prisma
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
USER nextjs
@@ -58,4 +60,5 @@ ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
ENV DATABASE_URL="file:./data/dev.db"
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "server.js"]

11
docker-entrypoint.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
# Wait for database to be ready
echo "Initializing database..."
# Apply migrations / create database schema
npx prisma db push --skip-generate
echo "Starting application..."
exec "$@"