File size: 1,140 Bytes
67e8759
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/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