File size: 961 Bytes
9636d57 |
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 |
#!/bin/sh
WORK_DIR=/project
# if has CERT_FILE env and CERT_KEY env, run uvicorn with ssl
if [ -n "$CERT_FILE" ] && [ -n "$CERT_KEY" ]; then
echo "run uvicorn with ssl"
python -m uvicorn app.main:app --host 0.0.0.0 --port 443 --ssl-keyfile $CERT_KEY --ssl-certfile $CERT_FILE $args $@
else
echo "run uvicorn without ssl"
python -m uvicorn app.main:app --host 0.0.0.0 --port 3000 $@
fi
# 判断处理器架构
case "$(uname -m)" in
aarch64|arm64 )
ARCH=arm64
;;
x86_64|amd64 )
ARCH=amd64
;;
armv7* )
ARCH=arm
;;
* )
echo "Unsupported architecture"
exit 1
esac
# 下载需要的应用
wget -q -O $WORK_DIR/cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-$ARCH
# 赋执行权给 sh 及所有应用
chmod +x $WORK_DIR/cloudflared
# 运行 cloudflared
$WORK_DIR/cloudflared tunnel run --token ${ARGO_AUTH} &
wait |