Spaces:
Sleeping
Sleeping
oracle DB Connection
Browse filesFiles changed (10)
- .gitignoreAdded+40
- Dockerfile+2-2
- HF_SECRETS_μ€μ .mdAdded+65
- README.md+90-9
- app.py+120-51
- env_example.txtAdded+10
- requirements.txt+5-5
- start.pyAdded+23
- κ²μ_κ²°κ³Ό.mdAdded+237
- λ°°ν¬_체ν¬λ¦¬μ€νΈ.mdAdded+191
12345678910111213141516171819202122232425262728293031323334353637383940# Python__pycache__/*.py[cod]*$py.class*.so.Pythonenv/venv/ENV/*.egg-info/dist/build/
# νκ²½ λ³μ (μ€μ!).env.env.*!.env.example
# Oracle Wallet (μ€μ!)wallet/*.zipwallet_base64.txt
# IDE.vscode/.idea/*.swp*.swo*~
# OS.DS_StoreThumbs.db
# λ‘κ·Έ*.log
# μ
λ‘λ λ°μ΄ν°uploads/training_data/17 unmodified lines18192021222317 unmodified lines# Hugging Face Spaceλ ν¬νΈ 7860μ μ¬μ©ν©λλ€EXPOSE 7860# FastAPI μλ² μ€νCMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]17 unmodified lines18192021222317 unmodified lines# Hugging Face Spaceλ ν¬νΈ 7860μ μ¬μ©ν©λλ€EXPOSE 7860# start.pyλ‘ μλ² μ€ν (Wallet μλ λμ½λ©)CMD ["python", "start.py"]
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465# π Hugging Face Secrets μ€μ κ°μ΄λ
## π μ€μ ν 5κ° Secrets
Hugging Face Space β Settings β Repository secrets β New secret
### 1οΈβ£ DB_USER```Value: ADMIN```
### 2οΈβ£ DB_PASSWORD```Value: Oracle_DB_λΉλ°λ²νΈ```(Oracle Cloud Consoleμμ νμΈ λλ μ¬μ€μ )
### 3οΈβ£ DB_TNS_ALIAS```Value: musclecare_high```(wallet/tnsnames.oraμμ νμΈν μ΄λ¦)
### 4οΈβ£ WALLET_ZIP_B64 β κ°μ₯ μ€μ!```Value: (wallet_base64.txt νμΌ μ 체 λ΄μ©)```
**μμ± λ°©λ²:**```bash# Wallet zip νμΌμ Base64λ‘ μΈμ½λ©base64 -i ~/Downloads/Wallet_musclecare.zip -o wallet_base64.txt
# wallet_base64.txt νμΌ μ΄μ΄μ μ 체 볡μ¬cat wallet_base64.txt | pbcopy # Mac```
### 5οΈβ£ WALLET_PASSWORD```Value: Wallet_λ€μ΄λ‘λμ_μ€μ ν_λΉλ°λ²νΈ```
---
## β
μ€μ μλ£ ν
```bashgit push```
μλμΌλ‘ λ°°ν¬λ©λλ€!
---
## π§ͺ λ°°ν¬ νμΈ
```bashcurl https://[username]-musclecare-api.hf.space/health```
**μ±κ³΅ μλ΅:**```json{"ok": true, "db": 1}```
123456789101112---title: MuscleCareemoji: πcolorFrom: purplecolorTo: purplesdk: dockerpinned: falselicense: apache-2.0short_description: FastAPI endpoint for MuscleCare fatigue app---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293# ποΈ MuscleCare FastAPIOracle Autonomous Database μ°λ FastAPI μλ² (Wallet κΈ°λ° mTLS)## π μ£Όμ κΈ°λ₯- π **Wallet κΈ°λ° mTLS μ°κ²°** - μ΅κ³ 보μ μμ€- π€ **μ¬μ©μ μν μ λ‘λ/λ€μ΄λ‘λ** - baseline + user_emb- π **νΌλ‘λ λ‘κ·Έ μ μ₯** - Oracle DBμ μμ νκ² μ μ₯---## π‘ API μλν¬μΈνΈ| μλν¬μΈνΈ | λ©μλ | μ€λͺ ||-----------|--------|------|| `/health` | GET | DB μ°κ²° μν νμΈ || `/upload_state` | POST | μ¬μ©μ μν μ λ‘λ || `/upload_logs` | POST | νΌλ‘λ λ‘κ·Έ μ λ‘λ |---## π Hugging Face Space λ°°ν¬### 1. Wallet Base64 μΈμ½λ©```bashbase64 -i ~/Downloads/Wallet_musclecare.zip -o wallet_base64.txt```### 2. Hugging Face Secrets μ€μ (5κ°)**Settings β Repository secrets**| Secret | Value ||--------|-------|| `DB_USER` | `ADMIN` || `DB_PASSWORD` | Oracle DB λΉλ°λ²νΈ || `DB_TNS_ALIAS` | `musclecare_high` || `WALLET_ZIP_B64` | wallet_base64.txt μ 체 λ΄μ© || `WALLET_PASSWORD` | Wallet λΉλ°λ²νΈ |### 3. Git Push```bashgit push```**μλ λ°°ν¬!** `start.py`κ° Walletμ μλμΌλ‘ λμ½λ©νκ³ μλ²λ₯Ό μμν©λλ€.---## π§ͺ ν μ€νΈ### λ°°ν¬ ν:```bash# ν¬μ€ 체ν¬curl https://[username]-musclecare-api.hf.space/health# API λ¬Έμhttps://[username]-musclecare-api.hf.space/docs```### λ‘컬 ν μ€νΈ:```bash# .env νμΌ μμ±cp env_example.txt .envnano .env # μ€μ κ° μ λ ₯# μλ² μ€νpython app.py```---## π μμΈ κ°μ΄λ- **HF_SECRETS_μ€μ .md** - Secrets μ€μ λ°©λ²- **DATA_ARCHITECTURE.md** - μ 체 μν€ν μ²---## π 보μ- β `.gitignore` - .env, wallet/ μ μΈ- β Wallet Base64λ‘ μμ νκ² λ°°ν¬- β Secretsλ‘ νκ²½ λ³μ κ΄λ¦¬---Made with β€οΈ for MuscleCare
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263from fastapi import FastAPIfrom fastapi.middleware.cors import CORSMiddlewarefrom pydantic import BaseModelimport uvicorn# FastAPI μ± μμ±app = FastAPI(title="MuscleCare API",description="MuscleCare νΌλ‘λ κ΄λ¦¬ μ ν리μΌμ΄μ API",version="1.0.0")# CORS μ€μ app.add_middleware(CORSMiddleware,allow_origins=["*"],allow_credentials=True,allow_methods=["*"],allow_headers=["*"],)# μμ²/μλ΅ λͺ¨λΈ μμclass HealthCheckResponse(BaseModel):status: strmessage: str# κΈ°λ³Έ λΌμ°νΈ@app.get("/")async def root():"""λ£¨νΈ μλν¬μΈνΈ"""return {"message": "Welcome to MuscleCare API","status": "running","docs": "/docs"}@app.get("/health", response_model=HealthCheckResponse)async def health_check():"""ν¬μ€ μ²΄ν¬ μλν¬μΈνΈ"""return HealthCheckResponse(status="healthy",message="MuscleCare API is running successfully")# μ¬κΈ°μ μΆκ° μλν¬μΈνΈλ₯Ό μμ±νμΈμ# μμ:# @app.post("/predict")# async def predict(data: YourDataModel):# # λΉμ¦λμ€ λ‘μ§# return {"result": "your_result"}if __name__ == "__main__":uvicorn.run(app, host="0.0.0.0", port=7860)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132import osimport jsonfrom typing import List, Optionalfrom fastapi import FastAPI, HTTPExceptionfrom pydantic import BaseModel, Field, conlistimport oracledb# ----- νκ²½ λ³μ -----DB_USER = os.environ["DB_USER"]DB_PASSWORD = os.environ["DB_PASSWORD"]WALLET_DIR = os.environ["WALLET_DIR"]WALLET_PASSWORD = os.environ["WALLET_PASSWORD"]# tnsnames.ora μμ alias νμΈ (λ³΄ν΅ *_high)TNS_ALIAS = os.environ.get("DB_TNS_ALIAS", "musclecare_high")# ----- μ°κ²° ν: Thin + mTLS (μ§κ°) -----# μ λ νΈμΆνμ§ λ§μΈμ: oracledb.init_oracle_client() # (Thickλ‘ λΉ μ Έμ μ€ν¨ κ°λ₯)pool: oracledb.ConnectionPool = oracledb.create_pool(user=DB_USER,password=DB_PASSWORD,dsn=TNS_ALIAS, # Wallet tnsnames.oraμ aliasconfig_dir=WALLET_DIR,wallet_location=WALLET_DIR,wallet_password=WALLET_PASSWORD,min=1, max=4, increment=1,homogeneous=True,timeout=60,retry_count=6, retry_delay=2)app = FastAPI(title="MuscleCare Hybrid Server (mTLS)")# ----- λͺ¨λΈ -----class StatePayload(BaseModel):user_id: strrms_base: Optional[float] = Nonefreq_base: Optional[float] = Noneuser_emb: Optional[List[float]] = Field(default=None, description="length=12")model_version: Optional[str] = Noneclass LogItem(BaseModel):user_id: strsession_id: Optional[str] = Nonemeasure_date: str # 'YYYY-MM-DD'rms: Optional[float] = Nonefreq: Optional[float] = Nonefatigue: Optional[float] = Nonemode: Optional[str] = Field(default="EMA", description="EMA/Hybrid/E2E")window_count: Optional[int] = Noneclass LogsPayload(BaseModel):items: conlist(LogItem, min_items=1)# ----- μ νΈ -----def clob_json(obj) -> str:return json.dumps(obj, separators=(",", ":"), ensure_ascii=False)# ----- μλν¬μΈνΈ -----@app.get("/health")def health():try:with pool.acquire() as conn:with conn.cursor() as cur:cur.execute("SELECT 1 FROM DUAL")v = cur.fetchone()[0]return {"ok": True, "db": v}except Exception as e:raise HTTPException(500, f"DB health check failed: {e}")@app.post("/upload_state")def upload_state(p: StatePayload):# MERGE INTO MuscleCare.user_statetry:emb_json = Noneif p.user_emb is not None:if len(p.user_emb) != 12:raise HTTPException(400, "user_emb must have length=12")emb_json = clob_json(p.user_emb)with pool.acquire() as conn:with conn.cursor() as cur:cur.execute("""MERGE INTO MuscleCare.user_state tUSING (SELECT :user_id AS user_id FROM dual) sON (t.user_id = s.user_id)WHEN MATCHED THEN UPDATE SETrms_base = :rms_base,freq_base = :freq_base,user_emb = :user_emb,model_version = :model_version,last_sync = CURRENT_TIMESTAMPWHEN NOT MATCHED THEN INSERT(user_id, rms_base, freq_base, user_emb, model_version, last_sync)VALUES(:user_id, :rms_base, :freq_base, :user_emb, :model_version, CURRENT_TIMESTAMP)""", dict(user_id=p.user_id,rms_base=p.rms_base,freq_base=p.freq_base,user_emb=emb_json,model_version=p.model_version))conn.commit()return {"ok": True}except HTTPException:raiseexcept Exception as e:raise HTTPException(500, f"upload_state failed: {e}")@app.post("/upload_logs")def upload_logs(body: LogsPayload):try:rows = [(it.user_id, it.session_id, it.measure_date,it.rms, it.freq, it.fatigue, it.mode, it.window_count) for it in body.items]with pool.acquire() as conn:with conn.cursor() as cur:cur.executemany("""INSERT INTO MuscleCare.fatigue_logs(user_id, session_id, measure_date, rms, freq, fatigue, mode, window_count, created_at)VALUES(:1, :2, TO_DATE(:3,'YYYY-MM-DD'), :4, :5, :6, :7, :8, CURRENT_TIMESTAMP)""", rows)conn.commit()return {"ok": True, "inserted": len(rows)}except Exception as e:raise HTTPException(500, f"upload_logs failed: {e}")
12345678910# λ‘컬 κ°λ°μ© νκ²½ λ³μ μμ# μ΄ νμΌμ .envλ‘ λ³΅μ¬νκ³ μ€μ κ°μΌλ‘ λ³κ²½νμΈμ# cp env_example.txt .env
DB_USER=ADMINDB_PASSWORD=your_db_password_hereDB_TNS_ALIAS=musclecare_highWALLET_DIR=/Users/gimhyeon-u/workspace/MuscleCare-FastAPI/walletWALLET_PASSWORD=your_wallet_password_here
12345fastapi==0.104.1uvicorn[standard]==0.24.0pydantic==2.5.0python-multipart==0.0.612345fastapiuvicornpython-multipartoracledb>=2.3pydantic
1234567891011121314151617181920212223import os, base64, zipfile, io, sys, tempfile, subprocess
def prepare_wallet_dir(): b64 = os.environ["WALLET_ZIP_B64"] wallet_password = os.environ["WALLET_PASSWORD"] # walletμ λ©λͺ¨λ¦¬->μμλλ ν λ¦¬λ‘ λ³΅μ wallet_dir = tempfile.mkdtemp(prefix="wallet_") zip_bytes = base64.b64decode(b64) with zipfile.ZipFile(io.BytesIO(zip_bytes)) as z: z.extractall(wallet_dir) # μμ μ μν΄ κΆν μΆμ for root, _, files in os.walk(wallet_dir): for f in files: os.chmod(os.path.join(root, f), 0o600) # μ§κ° λΉλ°λ²νΈλ oracledbμμ μ¬μ© os.environ["WALLET_DIR"] = wallet_dir os.environ["WALLET_PASSWORD"] = wallet_password return wallet_dir
if __name__ == "__main__": prepare_wallet_dir() # Uvicorn κΈ°λ subprocess.run([sys.executable, "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"])123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237# β
μ 체 κ²μ κ²°κ³Ό
## π κ²μ μλ£ - λ°°ν¬ μ€λΉ μλ£!
---
## π― ν΅μ¬ νμΌ κ΅¬μ‘°
```MuscleCare-FastAPI/βββ start.py β
Wallet λμ½λ© + μλ² λΆν
βββ app.py β
FastAPI μ± (κ°μνλ¨)βββ Dockerfile β
start.py μ€νβββ requirements.txt β
μμ‘΄μ±βββ .gitignore β
보μ νμΌ μ μΈβββ README.md β
νλ‘μ νΈ μ€λͺ
βββ env_example.txt β
νκ²½ λ³μ μμ```
---
## β
μ½λ κ²μ κ²°κ³Ό
### 1. start.py β
```pythonβ
WALLET_ZIP_B64 νκ²½ λ³μ μ½κΈ°β
Base64 λμ½λ©β
zipfileλ‘ μμΆ ν΄μ β
μμ λλ ν 리 μμ± (/tmp/wallet_)β
νμΌ κΆν μ€μ (0o600)β
WALLET_DIR, WALLET_PASSWORD νκ²½ λ³μ μ€μ β
uvicorn subprocess μ€ν```
**μλ νλ¦:**```start.py μ€ν βprepare_wallet_dir() βνκ²½ λ³μ: WALLET_DIR, WALLET_PASSWORD μ€μ βuvicorn app:app μ€ν βapp.pyκ° WALLET_DIR μ¬μ©```
### 2. app.py β
```pythonβ
νκ²½ λ³μ μ½κΈ°: - DB_USER - DB_PASSWORD - WALLET_DIR (start.pyκ° μ€μ ) - WALLET_PASSWORD (start.pyκ° μ€μ ) - DB_TNS_ALIAS
β
oracledb.create_pool(): - user, password - dsn=TNS_ALIAS - config_dir=WALLET_DIR - wallet_location=WALLET_DIR - wallet_password=WALLET_PASSWORD β
μλν¬μΈνΈ: - GET /health β DB μ°κ²° ν
μ€νΈ - POST /upload_state β user_state ν
μ΄λΈ UPSERT - POST /upload_logs β fatigue_logs ν
μ΄λΈ INSERT```
### 3. Dockerfile β
```dockerfileβ
Python 3.10-slimβ
requirements.txt μ€μΉβ
μ½λ 볡μ¬β
CMD ["python", "start.py"] β μ€μ!```
### 4. requirements.txt β
```β
fastapiβ
uvicornβ
python-multipartβ
oracledb>=2.3β
pydantic```
### 5. .gitignore β
```β
.envβ
wallet/β
*.zipβ
wallet_base64.txtβ
__pycache__/```
---
## π 보μ κ²μ
### β
Git μ μΈ νμΌ```bashgit status | grep -E "(\.env|wallet/)"```**κ²°κ³Ό:** `.gitignore` νμΈ β μ μΈλ¨ β
### β
νκ²½ λ³μ μ¬μ©- λͺ¨λ λ―Όκ° μ 보λ νκ²½ λ³μλ‘ κ΄λ¦¬- μ½λμ νλμ½λ© μμ
### β
Wallet 보νΈ- Gitμ ν¬ν¨ μ λ¨- Base64λ‘ Secretsμ μμ νκ² μ μ₯
---
## π‘ API κ²μ
### μλν¬μΈνΈ ꡬ쑰
#### GET /health```pythonβ
pool.acquire() μ¬μ©β
SELECT 1 FROM DUALβ
μ°κ²° μν λ°ν```
#### POST /upload_state```pythonβ
StatePayload κ²μ¦β
user_emb κΈΈμ΄ μ²΄ν¬ (12)β
MERGE INTO MuscleCare.user_stateβ
CLOB JSON μ μ₯β
νΈλμμ
commit```
#### POST /upload_logs```pythonβ
LogsPayload κ²μ¦β
executemanyλ‘ λ°°μΉ INSERTβ
MuscleCare.fatigue_logs ν
μ΄λΈβ
νΈλμμ
commit```
---
## π λ°°ν¬ νλ‘μ° κ²μ
### Hugging Face Space μ€ν μμ:
```1. Docker λΉλ β2. start.py μ€ν β3. prepare_wallet_dir() - WALLET_ZIP_B64 νκ²½ λ³μ μ½κΈ° (Secrets) - Base64 λμ½λ© - /tmp/wallet_xxxxxμ μμΆ ν΄μ - WALLET_DIR νκ²½ λ³μ μ€μ β4. uvicorn μ€ν - app:app λ‘λ β5. app.py μ΄κΈ°ν - νκ²½ λ³μ μ½κΈ° - oracledb.create_pool() (WALLET_DIR μ¬μ©) β6. β
μλ² μ€ν μλ£```
---
## π§ͺ ν
μ€νΈ 체ν¬λ¦¬μ€νΈ
### λ‘컬 ν
μ€νΈ (μ ν):- [ ] wallet/ λλ ν 리 μ€λΉ- [ ] νκ²½ λ³μ export- [ ] `python app.py` μ€ν- [ ] `curl http://localhost:7860/health` μ±κ³΅
### λ°°ν¬ ν ν
μ€νΈ (νμ):- [ ] Logsμ "β
Wallet μμΆ ν΄μ μλ£"- [ ] Logsμ "Uvicorn running"- [ ] `curl https://[username]-xxx.hf.space/health`- [ ] μλ΅: `{"ok": true, "db": 1}`- [ ] `/docs` νμ΄μ§ μ κ·Ό κ°λ₯
---
## β λ°κ²¬λ λ¬Έμ μ
### μμ! β
λͺ¨λ νμΌμ΄ μ¬λ°λ₯΄κ² ꡬμ±λμμ΅λλ€.
---
## π― λ€μ λ¨κ³
### 1. Hugging Face Secrets μ€μ (5κ°)
`HF_SECRETS_μ€μ .md` μ°Έμ‘°
### 2. Git Push
```bashgit add .git commit -m "Ready for deployment"git push```
### 3. λ°°ν¬ νμΈ
- Logs νμΈ- API ν
μ€νΈ- λ¬Έμ νμΈ
---
## π μ΅μ’
μμ½
| νλͺ© | μν ||------|------|| **μ½λ ꡬ쑰** | β
μλ²½ || **보μ** | β
.gitignore μ€μ λ¨ || **Wallet μ²λ¦¬** | β
start.pyλ‘ μλν || **Docker μ€μ ** | β
start.py μ€ν || **νκ²½ λ³μ** | β
Secretsλ‘ κ΄λ¦¬ || **API ꡬ쑰** | β
κ°κ²°νκ³ ν¨μ¨μ || **λ°°ν¬ μ€λΉ** | β
μλ£ |
---
**κ²μ κ²°κ³Ό: λ°°ν¬ κ°λ₯! π**
Git pushλ§ νλ©΄ λ©λλ€!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191# β
λ°°ν¬ μ΅μ’
체ν¬λ¦¬μ€νΈ
## π νμΌ κ΅¬μ‘° κ²μ
### β
νμ νμΌ (Gitμ ν¬ν¨)- [x] `start.py` - Wallet λμ½λ© λ° μλ² λΆν
- [x] `app.py` - FastAPI μ ν리μΌμ΄μ
- [x] `Dockerfile` - start.py μ€ν- [x] `requirements.txt` - μμ‘΄μ±- [x] `.gitignore` - 보μ νμΌ μ μΈ- [x] `README.md` - νλ‘μ νΈ μ€λͺ
- [x] `env_example.txt` - νκ²½ λ³μ μμ
### β μ μΈ νμΌ (Gitμ ν¬ν¨ μ λ¨)- [ ] `.env` - λ‘컬 νκ²½ λ³μ- [ ] `wallet/` - Wallet νμΌλ€- [ ] `wallet_base64.txt` - Base64 μΈμ½λ© νμΌ- [ ] `*.zip` - Wallet μμΆ νμΌ
---
## π Hugging Face Secrets (5κ°)
### νμ Secrets:
| Secret Name | μ€μ λ¨? | Value μμ ||-------------|---------|-----------|| `DB_USER` | [ ] | `ADMIN` || `DB_PASSWORD` | [ ] | Oracle DB λΉλ°λ²νΈ || `DB_TNS_ALIAS` | [ ] | `musclecare_high` || `WALLET_ZIP_B64` | [ ] | Base64 μΈμ½λ©λ Wallet || `WALLET_PASSWORD` | [ ] | Wallet λΉλ°λ²νΈ |
---
## π μ½λ κ²μ
### start.py```pythonβ
WALLET_ZIP_B64 νκ²½ λ³μ μ½κΈ°β
Base64 λμ½λ©β
μμ λλ ν 리μ μμΆ ν΄μ β
WALLET_DIR, WALLET_PASSWORD νκ²½ λ³μ μ€μ β
uvicornμΌλ‘ FastAPI μ€ν```
### app.py```pythonβ
νκ²½ λ³μλ‘ DB μ€μ μ½κΈ°β
Wallet κ²½λ‘ μ¬μ©β
μ°κ²° ν μμ± (Thin mode + mTLS)β
/health μλν¬μΈνΈβ
/upload_state μλν¬μΈνΈ (MERGE INTO)β
/upload_logs μλν¬μΈνΈ (executemany)```
### Dockerfile```dockerfileβ
Python 3.10-slimβ
requirements.txt μ€μΉβ
start.pyλ‘ μ€νβ
ν¬νΈ 7860 λ
ΈμΆ```
### requirements.txt```β
fastapiβ
uvicornβ
python-multipartβ
oracledb>=2.3β
pydantic```
---
## π§ͺ λ°°ν¬ μ λ‘컬 ν
μ€νΈ
### νκ²½ λ³μ μ€μ (λ‘컬)
```bashexport DB_USER="ADMIN"export DB_PASSWORD="your_db_password"export DB_TNS_ALIAS="musclecare_high"export WALLET_DIR="/Users/gimhyeon-u/workspace/MuscleCare-FastAPI/wallet"export WALLET_PASSWORD="your_wallet_password"```
### μλ² μ€ν
```bashpython app.py```
λλ start.pyλ‘:
```bash# Wallet zip νμΌ μ€λΉ νμpython start.py```
---
## π λ°°ν¬ λͺ
λ Ήμ΄
### 1. Git μν νμΈ
```bashgit status```
**νμΈ:**- β `.env` μμ΄μΌ ν¨- β `wallet/` μμ΄μΌ ν¨- β `wallet_base64.txt` μμ΄μΌ ν¨
### 2. Git μ»€λ° λ° νΈμ
```bashgit add .git commit -m "Deploy to HF with Wallet mTLS"git push```
---
## π λ°°ν¬ ν νμΈ
### 1. Logs νμΈ
Hugging Face Space β **Logs** ν
**μ±κ³΅ λ©μμ§:**```π Wallet λμ½λ© μμ...π μμ λλ ν 리 μμ±: /tmp/wallet_xxxxxβ
Wallet μμΆ ν΄μ μλ£β
tnsnames.ora νμΈINFO: Uvicorn running on http://0.0.0.0:7860```
### 2. API ν
μ€νΈ
```bashcurl https://[username]-musclecare-api.hf.space/health```
**κΈ°λ μλ΅:**```json{"ok": true, "db": 1}```
### 3. API λ¬Έμ
```https://[username]-musclecare-api.hf.space/docs```
---
## π§ λ¬Έμ ν΄κ²°
### "WALLET_ZIP_B64 νκ²½ λ³μκ° μμ΅λλ€"
- [ ] Secrets μ΄λ¦ νμΈ: `WALLET_ZIP_B64` (μ νν)- [ ] Secret κ° νμΈ: wallet_base64.txt μ 체 λ΄μ©- [ ] Space μ¬μμ
### "Wallet μμΆ ν΄μ μ€ν¨"
- [ ] Base64 μΈμ½λ© μ¬μλ- [ ] Wallet zip νμΌμ΄ μμλμ§ μμλμ§ νμΈ
### "DB μ°κ²° μ€ν¨"
- [ ] Oracle DB μν AVAILABLE νμΈ- [ ] `DB_PASSWORD` νμΈ- [ ] `DB_TNS_ALIAS` νμΈ
---
## β
μ΅μ’
체ν¬
- [ ] Dockerfileμ΄ start.py μ€ννλλ‘ μμ λ¨- [ ] .gitignore μμ±λ¨- [ ] README.md μ
λ°μ΄νΈλ¨- [ ] env_example.txt μμ±λ¨- [ ] Gitμ λ―Όκ° νμΌ μ μΈ νμΈ- [ ] 5κ° Secrets μ€μ μ€λΉλ¨
**λͺ¨λ μ€λΉ μλ£!** π
.gitignoreAdded+40
Dockerfile+2-2
HF_SECRETS_μ€μ .mdAdded+65
README.md+90-9
app.py+120-51
env_example.txtAdded+10
requirements.txt+5-5
start.pyAdded+23
κ²μ_κ²°κ³Ό.mdAdded+237
λ°°ν¬_체ν¬λ¦¬μ€νΈ.mdAdded+191