nex_buddy/docker/api-entrypoint.sh

26 lines
736 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
DATA_DIR="${DATA_DIR:-/app/data}"
mkdir -p "$DATA_DIR/media" "$DATA_DIR/firmware"
# 首次使用空目录挂载时,把镜像内置的码表种子放进去。
if [ ! -f "$DATA_DIR/regions.json" ] && [ -f /app/seed/regions.json ]; then
cp /app/seed/regions.json "$DATA_DIR/regions.json"
fi
cd /app/server
if [ "${RUN_MIGRATIONS:-1}" = "1" ]; then
echo ">> alembic upgrade head"
python -m alembic upgrade head
fi
echo ">> uvicorn :${BACKEND_PORT:-8100} (workers=${WEB_CONCURRENCY:-2})"
exec python -m uvicorn app.main:app \
--host 0.0.0.0 \
--port "${BACKEND_PORT:-8100}" \
--workers "${WEB_CONCURRENCY:-2}" \
--proxy-headers \
--forwarded-allow-ips "${FORWARDED_ALLOW_IPS:-*}"