feat: Add CI/CD migration runner to backend startup
This commit is contained in:
parent
df586b7c4e
commit
aa3faaa7e4
5 changed files with 22 additions and 1 deletions
|
|
@ -7,4 +7,8 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
# Make startup script executable
|
||||||
|
RUN chmod +x start.sh
|
||||||
|
|
||||||
|
# Run migrations then start server
|
||||||
|
CMD ["./start.sh"]
|
||||||
|
|
|
||||||
17
backend/start.sh
Normal file
17
backend/start.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "🔄 Running database migrations..."
|
||||||
|
|
||||||
|
# Run any migration scripts that exist
|
||||||
|
for script in /app/migrations/*.py; do
|
||||||
|
if [ -f "$script" ]; then
|
||||||
|
echo " Running: $(basename $script)"
|
||||||
|
python "$script" || echo " ⚠️ Migration $script failed (may already be applied)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "✅ Migrations complete. Starting server..."
|
||||||
|
|
||||||
|
# Start the main application
|
||||||
|
exec uvicorn main:app --host 0.0.0.0 --port 8000
|
||||||
Loading…
Add table
Reference in a new issue