Improved debugging by Cursor
Browse files- Dockerfile +11 -5
- launch.sh +37 -6
Dockerfile
CHANGED
@@ -11,7 +11,9 @@ ENV HOME=/home/user \
|
|
11 |
PATH=/home/user/.local/bin:$PATH
|
12 |
|
13 |
ENV UVICORN_WS_PROTOCOL=websockets
|
14 |
-
|
|
|
|
|
15 |
|
16 |
# Set the working directory
|
17 |
WORKDIR $HOME/app
|
@@ -19,14 +21,18 @@ WORKDIR $HOME/app
|
|
19 |
# Copy the app to the container
|
20 |
COPY --chown=user . $HOME/app
|
21 |
|
|
|
|
|
|
|
22 |
# Install the dependencies
|
23 |
-
# RUN uv sync --frozen
|
24 |
RUN uv sync
|
|
|
|
|
25 |
|
26 |
-
# Expose the port
|
27 |
EXPOSE 7860
|
28 |
-
|
29 |
EXPOSE 8000
|
30 |
|
31 |
# Run the app
|
32 |
-
CMD ["
|
|
|
11 |
PATH=/home/user/.local/bin:$PATH
|
12 |
|
13 |
ENV UVICORN_WS_PROTOCOL=websockets
|
14 |
+
# Make logs more verbose for debugging
|
15 |
+
ENV UVICORN_LOG_LEVEL=debug
|
16 |
+
ENV CHAINLIT_LOG_LEVEL=debug
|
17 |
|
18 |
# Set the working directory
|
19 |
WORKDIR $HOME/app
|
|
|
21 |
# Copy the app to the container
|
22 |
COPY --chown=user . $HOME/app
|
23 |
|
24 |
+
# Make launch script executable
|
25 |
+
RUN chmod +x ./launch.sh
|
26 |
+
|
27 |
# Install the dependencies
|
|
|
28 |
RUN uv sync
|
29 |
+
# Verify installed packages
|
30 |
+
RUN python -m pip list
|
31 |
|
32 |
+
# Expose the port - HF Spaces uses 7860 by default
|
33 |
EXPOSE 7860
|
34 |
+
# Backend port
|
35 |
EXPOSE 8000
|
36 |
|
37 |
# Run the app
|
38 |
+
CMD ["sh", "-c", "uv run ./launch.sh"]
|
launch.sh
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
#!/bin/bash
|
|
|
2 |
|
3 |
# Function to cleanup processes on exit
|
4 |
cleanup() {
|
@@ -10,16 +11,46 @@ cleanup() {
|
|
10 |
# Set up cleanup on script exit
|
11 |
trap cleanup EXIT
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Start backend on port 8000
|
14 |
-
echo "Starting backend on http://
|
15 |
-
uvicorn backend.main:app --
|
|
|
16 |
|
17 |
# Wait for backend to start
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
echo "Starting frontend on http://localhost:8501..."
|
22 |
-
chainlit run app.py --port 7860 &
|
23 |
|
24 |
# Wait for all background processes
|
25 |
wait
|
|
|
1 |
#!/bin/bash
|
2 |
+
set -e # Exit immediately if a command exits with a non-zero status
|
3 |
|
4 |
# Function to cleanup processes on exit
|
5 |
cleanup() {
|
|
|
11 |
# Set up cleanup on script exit
|
12 |
trap cleanup EXIT
|
13 |
|
14 |
+
# Display environment info for debugging
|
15 |
+
echo "=== Environment Information ==="
|
16 |
+
echo "Python version: $(python --version)"
|
17 |
+
echo "Current directory: $(pwd)"
|
18 |
+
echo "Files in directory: $(ls -l)"
|
19 |
+
echo "==============================="
|
20 |
+
|
21 |
# Start backend on port 8000
|
22 |
+
echo "Starting backend on http://0.0.0.0:8000..."
|
23 |
+
uvicorn backend.main:app --host 0.0.0.0 --port 8000 --log-level debug &
|
24 |
+
backend_pid=$!
|
25 |
|
26 |
# Wait for backend to start
|
27 |
+
echo "Waiting for backend to start..."
|
28 |
+
sleep 5
|
29 |
+
|
30 |
+
# Check if backend is running
|
31 |
+
if ! kill -0 $backend_pid 2>/dev/null; then
|
32 |
+
echo "ERROR: Backend failed to start!"
|
33 |
+
exit 1
|
34 |
+
fi
|
35 |
+
echo "Backend started successfully with PID $backend_pid"
|
36 |
+
|
37 |
+
# Start frontend on port 7860
|
38 |
+
echo "Starting frontend on http://0.0.0.0:7860..."
|
39 |
+
chainlit run app.py --host 0.0.0.0 --port 7860 &
|
40 |
+
frontend_pid=$!
|
41 |
+
|
42 |
+
# Wait for frontend to start
|
43 |
+
echo "Waiting for frontend to start..."
|
44 |
+
sleep 5
|
45 |
+
|
46 |
+
# Check if frontend is running
|
47 |
+
if ! kill -0 $frontend_pid 2>/dev/null; then
|
48 |
+
echo "ERROR: Frontend failed to start!"
|
49 |
+
exit 1
|
50 |
+
fi
|
51 |
+
echo "Frontend started successfully with PID $frontend_pid"
|
52 |
|
53 |
+
echo "All services started successfully!"
|
|
|
|
|
54 |
|
55 |
# Wait for all background processes
|
56 |
wait
|