Update entrypoint.sh
Browse files- entrypoint.sh +62 -76
entrypoint.sh
CHANGED
|
@@ -1,76 +1,62 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
ls -l /
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
USER appuser
|
| 64 |
-
|
| 65 |
-
# Verify /app/ exists and is accessible by appuser
|
| 66 |
-
RUN ls -ld /app/ || (echo "Error: /app/ directory missing for appuser" && exit 1) && \
|
| 67 |
-
ls -l /app/ || (echo "Error: Failed to list contents of /app/ as appuser" && exit 1)
|
| 68 |
-
|
| 69 |
-
# Copy and set up entrypoint
|
| 70 |
-
COPY entrypoint.sh /entrypoint.sh
|
| 71 |
-
RUN chmod +x /entrypoint.sh
|
| 72 |
-
|
| 73 |
-
# Use entrypoint to ensure working directory and run the app
|
| 74 |
-
# Also set CMD as a fallback in case ENTRYPOINT is overridden
|
| 75 |
-
ENTRYPOINT ["/entrypoint.sh"]
|
| 76 |
-
CMD ["/entrypoint.sh"]
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
echo "===== Entrypoint: Starting at $(date) ====="
|
| 3 |
+
echo "Entrypoint: Current user: $(id)"
|
| 4 |
+
echo "Entrypoint: Environment variables:"
|
| 5 |
+
env
|
| 6 |
+
|
| 7 |
+
echo "Entrypoint: Verifying directories exist"
|
| 8 |
+
mkdir -p /app /model /tmp/Ultralytics /snapshots || { echo "Error: Failed to create directories"; exit 1; }
|
| 9 |
+
chown appuser:appuser /app /model /tmp/Ultralytics /snapshots || { echo "Error: Failed to chown directories"; exit 1; }
|
| 10 |
+
chmod 777 /app /model /tmp/Ultralytics /snapshots || { echo "Error: Failed to chmod directories"; exit 1; }
|
| 11 |
+
echo "Entrypoint: Directory permissions:"
|
| 12 |
+
ls -ld /app /model /tmp/Ultralytics /snapshots
|
| 13 |
+
|
| 14 |
+
echo "Entrypoint: Copying yolov8n.pt to /app"
|
| 15 |
+
if [ -f /model/yolov8n.pt ]; then
|
| 16 |
+
cp /model/yolov8n.pt /app/yolov8n.pt || { echo "Error: Failed to copy yolov8n.pt"; exit 1; }
|
| 17 |
+
chown appuser:appuser /app/yolov8n.pt
|
| 18 |
+
chmod 644 /app/yolov8n.pt
|
| 19 |
+
else
|
| 20 |
+
echo "Error: /model/yolov8n.pt not found. Build may have failed."
|
| 21 |
+
exit 1
|
| 22 |
+
fi
|
| 23 |
+
|
| 24 |
+
echo "Entrypoint: Copying app.py to /app (in case Hugging Face mount overwrites it)"
|
| 25 |
+
if [ -f /source/app.py ]; then
|
| 26 |
+
cp /source/app.py /app/app.py || { echo "Error: Failed to copy app.py"; exit 1; }
|
| 27 |
+
chown appuser:appuser /app/app.py
|
| 28 |
+
chmod 644 /app/app.py
|
| 29 |
+
else
|
| 30 |
+
echo "Error: /source/app.py not found. Build may have failed."
|
| 31 |
+
exit 1
|
| 32 |
+
fi
|
| 33 |
+
|
| 34 |
+
echo "Entrypoint: Setting working directory to /app"
|
| 35 |
+
cd /app || { echo "Error: Failed to change directory to /app"; exit 1; }
|
| 36 |
+
|
| 37 |
+
echo "Entrypoint: Current working directory: $(pwd)"
|
| 38 |
+
echo "Entrypoint: Contents of /app:"
|
| 39 |
+
ls -l /app || echo "Error: Failed to list /app contents"
|
| 40 |
+
|
| 41 |
+
echo "Entrypoint: Verifying yolov8n.pt exists in /app"
|
| 42 |
+
if [ ! -f /app/yolov8n.pt ]; then
|
| 43 |
+
echo "Error: yolov8n.pt not found in /app after copy. Directory contents:"
|
| 44 |
+
ls -l /app
|
| 45 |
+
exit 1
|
| 46 |
+
fi
|
| 47 |
+
|
| 48 |
+
echo "Entrypoint: Verifying app.py exists in /app"
|
| 49 |
+
if [ ! -f /app/app.py ]; then
|
| 50 |
+
echo "Error: app.py not found in /app after copy. Directory contents:"
|
| 51 |
+
ls -l /app
|
| 52 |
+
exit 1
|
| 53 |
+
fi
|
| 54 |
+
|
| 55 |
+
echo "Entrypoint: Contents of /home/user/app (Hugging Face mount point):"
|
| 56 |
+
ls -l /home/user/app || echo "Directory /home/user/app does not exist"
|
| 57 |
+
|
| 58 |
+
echo "Entrypoint: Contents of /source (persistent storage):"
|
| 59 |
+
ls -l /source || echo "Directory /source does not exist"
|
| 60 |
+
|
| 61 |
+
echo "Entrypoint: Launching application"
|
| 62 |
+
exec python /app/app.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|