Spaces:
Sleeping
Sleeping
Update entrypoint.sh
Browse files- entrypoint.sh +29 -5
entrypoint.sh
CHANGED
|
@@ -1,20 +1,23 @@
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
set -euo pipefail
|
| 3 |
|
| 4 |
-
# --- Réglages (surchageables en Variables
|
| 5 |
: "${GITHUB_REPO_API_URL:=https://github.com/chourmovs/RFPmasterApi.git}"
|
| 6 |
: "${GITHUB_REPO_CORE_URL:=https://github.com/chourmovs/RFPmaster.git}"
|
| 7 |
: "${GITHUB_TOKEN:=}" # si besoin pour repos privés
|
| 8 |
-
: "${API_MODULE:=rfp_api_app}" #
|
| 9 |
: "${API_APP_ATTR:=app}"
|
| 10 |
-
: "${BRANCH_API:=}" # ex: main ; vide = HEAD
|
| 11 |
: "${BRANCH_CORE:=}" # ex: main
|
| 12 |
: "${WORKSPACE:=/home/user/workspace}"
|
| 13 |
|
| 14 |
-
#
|
|
|
|
|
|
|
| 15 |
API_DIR="${WORKSPACE}/RFPmasterApi"
|
| 16 |
CORE_DIR="${WORKSPACE}/RFPmaster" # contiendra rfp_parser/
|
| 17 |
|
|
|
|
| 18 |
echo "[startup] WORKSPACE=${WORKSPACE}"
|
| 19 |
mkdir -p "${WORKSPACE}"
|
| 20 |
|
|
@@ -47,7 +50,28 @@ clone_or_update "${GITHUB_REPO_CORE_URL}" "${CORE_DIR}" "${BRANCH_CORE}"
|
|
| 47 |
git config --global --add safe.directory "${API_DIR}" || true
|
| 48 |
git config --global --add safe.directory "${CORE_DIR}" || true
|
| 49 |
|
| 50 |
-
# ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
export PYTHONPATH="${API_DIR}:${CORE_DIR}:${PYTHONPATH:-}"
|
| 52 |
|
| 53 |
# --- Sanity checks imports ---
|
|
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
set -euo pipefail
|
| 3 |
|
| 4 |
+
# --- Réglages (surchageables en Variables/Secrets HF) ---
|
| 5 |
: "${GITHUB_REPO_API_URL:=https://github.com/chourmovs/RFPmasterApi.git}"
|
| 6 |
: "${GITHUB_REPO_CORE_URL:=https://github.com/chourmovs/RFPmaster.git}"
|
| 7 |
: "${GITHUB_TOKEN:=}" # si besoin pour repos privés
|
| 8 |
+
: "${API_MODULE:=rfp_api_app}" # module exposant 'app'
|
| 9 |
: "${API_APP_ATTR:=app}"
|
| 10 |
+
: "${BRANCH_API:=}" # ex: main ; vide = HEAD
|
| 11 |
: "${BRANCH_CORE:=}" # ex: main
|
| 12 |
: "${WORKSPACE:=/home/user/workspace}"
|
| 13 |
|
| 14 |
+
# Assure que ~/.local/bin (pip --user) est dans le PATH
|
| 15 |
+
export PATH="/home/user/.local/bin:/usr/local/bin:/usr/bin:/bin:${PATH}"
|
| 16 |
+
|
| 17 |
API_DIR="${WORKSPACE}/RFPmasterApi"
|
| 18 |
CORE_DIR="${WORKSPACE}/RFPmaster" # contiendra rfp_parser/
|
| 19 |
|
| 20 |
+
echo "===== Application Startup at $(date '+%F %T') ====="
|
| 21 |
echo "[startup] WORKSPACE=${WORKSPACE}"
|
| 22 |
mkdir -p "${WORKSPACE}"
|
| 23 |
|
|
|
|
| 50 |
git config --global --add safe.directory "${API_DIR}" || true
|
| 51 |
git config --global --add safe.directory "${CORE_DIR}" || true
|
| 52 |
|
| 53 |
+
# --- Installation des dépendances Python (au run) ---
|
| 54 |
+
echo "[pip] Checking uvicorn presence..."
|
| 55 |
+
if ! command -v uvicorn >/dev/null 2>&1; then
|
| 56 |
+
echo "[pip] uvicorn not found → installing requirements"
|
| 57 |
+
if [ -f "${API_DIR}/requirements.txt" ]; then
|
| 58 |
+
# --user pour installer dans ~/.local et éviter les droits root
|
| 59 |
+
python -m pip install --user --no-cache-dir -r "${API_DIR}/requirements.txt"
|
| 60 |
+
else
|
| 61 |
+
# garde-fou minimal
|
| 62 |
+
python -m pip install --user --no-cache-dir fastapi "uvicorn[standard]" requests pandas openpyxl
|
| 63 |
+
fi
|
| 64 |
+
else
|
| 65 |
+
echo "[pip] uvicorn OK"
|
| 66 |
+
fi
|
| 67 |
+
|
| 68 |
+
# (Optionnel) si ton repo CORE a aussi un requirements.txt :
|
| 69 |
+
if [ -f "${CORE_DIR}/requirements.txt" ]; then
|
| 70 |
+
echo "[pip] Installing CORE requirements"
|
| 71 |
+
python -m pip install --user --no-cache-dir -r "${CORE_DIR}/requirements.txt" || true
|
| 72 |
+
fi
|
| 73 |
+
|
| 74 |
+
# --- PYTHONPATH : on expose les deux répertoires (API + CORE/rfp_parser) ---
|
| 75 |
export PYTHONPATH="${API_DIR}:${CORE_DIR}:${PYTHONPATH:-}"
|
| 76 |
|
| 77 |
# --- Sanity checks imports ---
|