Skip to content

Commit 99e38d4

Browse files
committed
feat(entrypoint): ensure metrics directory exists
Create the /app/metrics directory if it does not exist. Set proper ownership (django:django) and permissions (755), handling both root and non-root execution contexts.
1 parent 859b541 commit 99e38d4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docker-entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ else
3636
echo "Warning: Running as non-root, may not be able to set media permissions"
3737
fi
3838

39+
# Check if the metrics directory exists
40+
if [ ! -d "/app/metrics" ]; then
41+
echo "Creating metrics directory for persistent metrics storage..."
42+
mkdir -p /app/metrics
43+
fi
44+
45+
# Ensure proper permissions for metrics directory
46+
# Run as root to set permissions, then switch back
47+
if [ "$(id -u)" = "0" ]; then
48+
chown -R django:django /app/metrics
49+
chmod -R 755 /app/metrics
50+
else
51+
echo "Warning: Running as non-root, may not be able to set metrics permissions"
52+
fi
53+
3954
# Change to app directory
4055
cd /app
4156

0 commit comments

Comments
 (0)