fix(DB): migrate the DB on container launch

This commit is contained in:
Willie Zutz 2025-05-27 13:18:18 -06:00
parent 011d10df29
commit 631906da35
2 changed files with 24 additions and 2 deletions

View file

@ -25,11 +25,18 @@ COPY --from=builder /home/perplexica/.next/static ./public/_next/static
COPY --from=builder /home/perplexica/.next/standalone ./
COPY --from=builder /home/perplexica/data ./data
# Copy files needed for database migrations at runtime
COPY drizzle.config.ts ./
COPY src/lib/db/schema.ts ./src/lib/db/
COPY docker-entrypoint.sh ./
COPY package.json ./
RUN mkdir /home/perplexica/uploads && \
chmod +x /home/perplexica/docker-entrypoint.sh && \
npx -y playwright install chromium --with-deps && \
npm install playwright && \
npm install playwright drizzle-kit && \
apt-get update && \
apt-get install -y procps && \
apt-get clean && rm -rf /var/lib/apt/lists/*
CMD ["node", "server.js"]
CMD ["./docker-entrypoint.sh"]

15
docker-entrypoint.sh Normal file
View file

@ -0,0 +1,15 @@
#!/bin/bash
set -e
echo "🚀 Starting Perplexica..."
# Ensure data directory exists
mkdir -p /home/perplexica/data
# Run database schema migration
echo "📊 Updating database schema..."
npm run db:push
# Start the application
echo "🌐 Starting Next.js server..."
exec node server.js