Spaces:
Sleeping

axeronis commited on
Commit
2b47929
Β·
1 Parent(s): 6438992

fix: use dedicated start.sh for reliable startup debugging

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -2
  2. backend/start.sh +23 -6
Dockerfile CHANGED
@@ -30,5 +30,6 @@ WORKDIR /app/backend
30
  # Set environment variables
31
  ENV PYTHONUNBUFFERED=1
32
 
33
- # Run command (matches nixpacks.toml behavior)
34
- CMD ["sh", "-c", "set -e && alembic upgrade head && python -m uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8000}"]
 
 
30
  # Set environment variables
31
  ENV PYTHONUNBUFFERED=1
32
 
33
+ # Set permissions and run
34
+ RUN chmod +x /app/backend/start.sh
35
+ CMD ["/app/backend/start.sh"]
backend/start.sh CHANGED
@@ -1,11 +1,28 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- echo "Installing dependencies..."
5
- pip install -r requirements.txt
 
 
6
 
7
- echo "Applying LinkedIn migration..."
8
- cd /app/backend && python apply_linkedin_migration.py || echo "⚠️ Migration failed (continuing anyway)"
 
9
 
10
- echo "Starting FastAPI server..."
11
- cd /app/backend && uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8000}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ # Logging function
5
+ log() {
6
+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
7
+ }
8
 
9
+ log "πŸš€ Starting MicroFunnel Backend..."
10
+ log "πŸ“‚ Working Directory: $(pwd)"
11
+ log "πŸ‘€ User: $(whoami)"
12
 
13
+ # 1. Run Migrations
14
+ log "πŸ› οΈ Running Database Migrations..."
15
+ if alembic upgrade head; then
16
+ log "βœ… Migrations applied successfully."
17
+ else
18
+ log "❌ Migration failed!"
19
+ exit 1
20
+ fi
21
+
22
+ # 2. Verify Port
23
+ PORT="${PORT:-8000}"
24
+ log "πŸ”Œ Starting Server on 0.0.0.0:$PORT"
25
+
26
+ # 3. Start Uvicorn
27
+ # Use exec to replace shell process with uvicorn for signal handling
28
+ exec python -m uvicorn app.main:app --host 0.0.0.0 --port "$PORT" --log-level info