ds361 / entrypoint.sh
Spooker's picture
Upload 12 files
67e8759 verified
#!/bin/sh
set -eu
cd /app
# Hugging Face Spaces exposes the external HTTP port configured in README.md as app_port.
# The ds2api binary defaults to 5001; keep PORT aligned unless the user overrides it.
export PORT="${PORT:-5001}"
export DS2API_STATIC_ADMIN_DIR="${DS2API_STATIC_ADMIN_DIR:-/app/static/admin}"
if [ -n "${DS2API_CONFIG_JSON:-}" ]; then
printf '%s' "$DS2API_CONFIG_JSON" > /tmp/ds2api_config.json
export DS2API_CONFIG_PATH=/tmp/ds2api_config.json
elif [ -n "${DS2API_CONFIG_PATH:-}" ]; then
if [ ! -f "$DS2API_CONFIG_PATH" ]; then
echo "DS2API_CONFIG_PATH is set but file does not exist: $DS2API_CONFIG_PATH" >&2
exit 1
fi
elif [ -f /app/config.json ]; then
export DS2API_CONFIG_PATH=/app/config.json
else
cp /app/config.example.json /tmp/config.json
export DS2API_CONFIG_PATH=/tmp/config.json
echo "WARNING: no DS2API_CONFIG_JSON or config.json found; using config.example.json. Configure secrets before production use." >&2
fi
if [ -z "${DS2API_ADMIN_KEY:-}" ]; then
echo "WARNING: DS2API_ADMIN_KEY is not set. Set it in Space secrets before production use." >&2
fi
exec /usr/local/bin/ds2api