| #!/bin/sh |
| echo "===== Entrypoint: Starting at $(date) =====" |
| echo "Entrypoint: Current user: $(id)" |
| echo "Entrypoint: Environment variables:" |
| env |
|
|
| echo "Entrypoint: Verifying directories exist" |
| mkdir -p /app /model /tmp/Ultralytics /snapshots || { echo "Error: Failed to create directories"; exit 1; } |
| chown appuser:appuser /app /model /tmp/Ultralytics /snapshots || { echo "Error: Failed to chown directories"; exit 1; } |
| chmod 777 /app /model /tmp/Ultralytics /snapshots || { echo "Error: Failed to chmod directories"; exit 1; } |
| echo "Entrypoint: Directory permissions:" |
| ls -ld /app /model /tmp/Ultralytics /snapshots |
|
|
| echo "Entrypoint: Copying yolov8n.pt to /app" |
| if [ -f /model/yolov8n.pt ]; then |
| cp /model/yolov8n.pt /app/yolov8n.pt || { echo "Error: Failed to copy yolov8n.pt"; exit 1; } |
| chown appuser:appuser /app/yolov8n.pt |
| chmod 644 /app/yolov8n.pt |
| else |
| echo "Error: /model/yolov8n.pt not found. Build may have failed." |
| exit 1 |
| fi |
|
|
| echo "Entrypoint: Copying app.py to /app (in case Hugging Face mount overwrites it)" |
| if [ -f /source/app.py ]; then |
| cp /source/app.py /app/app.py || { echo "Error: Failed to copy app.py"; exit 1; } |
| chown appuser:appuser /app/app.py |
| chmod 644 /app/app.py |
| else |
| echo "Error: /source/app.py not found. Build may have failed." |
| exit 1 |
| fi |
|
|
| echo "Entrypoint: Setting working directory to /app" |
| cd /app || { echo "Error: Failed to change directory to /app"; exit 1; } |
|
|
| echo "Entrypoint: Current working directory: $(pwd)" |
| echo "Entrypoint: Contents of /app:" |
| ls -l /app || echo "Error: Failed to list /app contents" |
|
|
| echo "Entrypoint: Verifying yolov8n.pt exists in /app" |
| if [ ! -f /app/yolov8n.pt ]; then |
| echo "Error: yolov8n.pt not found in /app after copy. Directory contents:" |
| ls -l /app |
| exit 1 |
| fi |
|
|
| echo "Entrypoint: Verifying app.py exists in /app" |
| if [ ! -f /app/app.py ]; then |
| echo "Error: app.py not found in /app after copy. Directory contents:" |
| ls -l /app |
| exit 1 |
| fi |
|
|
| echo "Entrypoint: Contents of /home/user/app (Hugging Face mount point):" |
| ls -l /home/user/app || echo "Directory /home/user/app does not exist" |
|
|
| echo "Entrypoint: Contents of /source (persistent storage):" |
| ls -l /source || echo "Directory /source does not exist" |
|
|
| echo "Entrypoint: Launching application" |
| exec python /app/app.py |