Refactor production setup and database management

- Updated Dockerfile for production to ensure proper database permissions and improved startup script.
- Removed outdated PRODUCTION_README.md and consolidated relevant information into other documentation.
- Enhanced deploy.sh script to fix database permissions and streamline deployment process.
- Modified docker-compose configuration to use a dedicated production file and adjusted port mappings.
- Removed legacy docker-compose.yml file to avoid confusion.
- Improved session management by refining secure cookie settings based on environment variables.
- Deleted obsolete Nginx configuration and old seed scripts to clean up the project structure.
- Updated database setup scripts to reflect new structure and removed old seed data scripts.
- Adjusted reset-db script to use environment variable for database path.
- Enhanced setup-database script to provide dynamic admin credentials in the summary.
- Removed unnecessary backup file for SQLite database.
This commit is contained in:
2025-09-28 16:32:31 +01:00
parent 6706ba7f1f
commit 2d31c49235
19 changed files with 69 additions and 1143 deletions
+18 -11
View File
@@ -32,14 +32,21 @@ fi
echo "🛠️ Setting up the database..."
npx tsx scripts/setup-database.ts
# Fix database permissions for container
echo "🔒 Fixing database permissions for container..."
if [ -f "data/sqlite.db" ]; then
chmod 666 data/sqlite.db
fi
chmod 777 data backups logs
# Build and deploy with Docker Compose
echo "🐳 Building and starting Docker containers..."
# Stop existing containers
docker-compose -f docker-compose.production.yml down || echo "No existing containers to stop"
docker compose -f docker-compose.production.yml down || echo "No existing containers to stop"
# Build and start containers
docker-compose -f docker-compose.production.yml up -d --build
docker compose -f docker-compose.production.yml up -d --build
# Wait for containers to be healthy
echo "⏳ Waiting for containers to be healthy..."
@@ -48,13 +55,13 @@ sleep 30
# Check health
echo "🔍 Checking application health..."
for i in {1..10}; do
if curl -f http://localhost:3000/api/health >/dev/null 2>&1; then
if curl -f http://localhost:3036/api/health >/dev/null 2>&1; then
echo "✅ Application is healthy!"
break
elif [ $i -eq 10 ]; then
echo "❌ Application health check failed after 10 attempts"
echo "📋 Container logs:"
docker-compose -f docker-compose.production.yml logs tt-booking
docker compose -f docker-compose.production.yml logs tt-booking
exit 1
else
echo "⏳ Attempt $i/10: Application not ready yet, waiting..."
@@ -64,24 +71,24 @@ done
# Show running containers
echo "📊 Running containers:"
docker-compose -f docker-compose.production.yml ps
docker compose -f docker-compose.production.yml ps
# Show logs
echo "📋 Recent application logs:"
docker-compose -f docker-compose.production.yml logs --tail=20 tt-booking
docker compose -f docker-compose.production.yml logs --tail=20 tt-booking
echo ""
echo "🎉 Deployment completed successfully!"
echo ""
echo "📊 Application Status:"
echo " • URL: https://lcc-tt-booking.mikicvi.com"
echo " • Health Check: http://localhost:3000/api/health"
echo " • Container Status: $(docker-compose -f docker-compose.production.yml ps -q tt-booking | xargs docker inspect -f '{{.State.Status}}')"
echo " • Health Check: http://localhost:3036/api/health"
echo " • Container Status: $(docker compose -f docker-compose.production.yml ps -q tt-booking | xargs docker inspect -f '{{.State.Status}}')"
echo ""
echo "🔧 Useful commands:"
echo " • View logs: docker-compose -f docker-compose.production.yml logs -f tt-booking"
echo " • Restart: docker-compose -f docker-compose.production.yml restart tt-booking"
echo " • Stop: docker-compose -f docker-compose.production.yml down"
echo " • View logs: docker compose -f docker-compose.production.yml logs -f tt-booking"
echo " • Restart: docker compose -f docker-compose.production.yml restart tt-booking"
echo " • Stop: docker compose -f docker-compose.production.yml down"
echo ""
echo "⚠️ Don't forget to:"
echo " 1. Set up Cloudflare Tunnel to expose your application"