init: dbx-corm 프로젝트 Docker 기반 마이그레이션

주요 변경사항:
- DB 접속정보를 환경변수(.env) 방식으로 분리
- orderlist_app → orderlist_db 변경 (main.py, routers/returns.py)
- 네이버/카페24 API 키도 환경변수로 분리
- Dockerfile / docker-compose.yml 작성 (외부 PostgreSQL 네트워크 연결)
- .gitignore: 민감파일(.env, cafe24_tokens.json, manual-ordering.json) 제외
- 불필요 파일 정리 (venv, __pycache__, 일회성 스크립트, xlsx 등)
- README.md / .env.example / push_to_gitea.bat 추가

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 15:11:34 +09:00
commit 6e438344d0
20 changed files with 8179 additions and 0 deletions
+146
View File
@@ -0,0 +1,146 @@
# DBX CORM (CS Web Program)
CS / 발주 / 반품 통합 관리 웹 애플리케이션.
FastAPI + PostgreSQL 기반, Docker로 실행.
---
## 기술 스택
- **Backend**: Python 3.10, FastAPI, Uvicorn
- **DB**: PostgreSQL (외부 Docker 컨테이너 연결)
- **외부 연동**: 네이버 커머스 API, 카페24 API, Google Sheets
- **Frontend**: Jinja2 템플릿 + Vanilla JS
---
## 사용 DB
| DB 이름 | 용도 |
|---|---|
| `itemcode_db` | 품목코드 마스터 |
| `orderlist_db` | 주문 정보 조회 |
| `return_db` | 반품 데이터 저장 |
모두 DB 계정은 `king` 통일.
---
## 서버 배포 절차 (`/opt/dbx-corm`)
### 1. 코드 받기
```bash
sudo mkdir -p /opt/dbx-corm
sudo chown $USER:$USER /opt/dbx-corm
cd /opt
git clone https://gitea.no1king.freeddns.org/king/dbx-corm.git
cd /opt/dbx-corm
```
### 2. 환경변수 설정
```bash
cp .env.example .env
nano .env
```
`.env` 파일에 다음을 채워주세요:
- `POSTGRES_PASSWORD` (DB 비밀번호)
- `POSTGRES_HOST` (PostgreSQL 컨테이너 이름. 아래로 확인)
- `NAVER_CLIENT_ID`, `NAVER_CLIENT_SECRET`
- `CAFE24_CLIENT_ID`, `CAFE24_CLIENT_SECRET`, `CAFE24_REDIRECT_URI`
PostgreSQL 컨테이너 이름 확인:
```bash
docker ps --filter "ancestor=postgres" --format "{{.Names}}"
```
### 3. PostgreSQL 네트워크 확인 / 수정
```bash
docker network ls | grep postgres
```
`docker-compose.yml``networks.postgres-net.name` 값을 실제 네트워크 이름으로 수정.
### 4. 민감 파일 업로드 (Git에 없음)
로컬 PC에서 서버로 직접 복사:
```bash
# 로컬 PC에서 실행
scp cafe24_tokens.json king@<서버>:/opt/dbx-corm/
scp manual-ordering.json king@<서버>:/opt/dbx-corm/
```
### 5. 빌드 및 실행
```bash
cd /opt/dbx-corm
docker compose up -d --build
```
### 6. 상태 확인
```bash
docker compose ps
docker compose logs -f
```
---
## 업데이트 (Git pull 후 재배포)
```bash
cd /opt/dbx-corm
git pull
docker compose up -d --build
```
---
## 접속
- 컨테이너 포트: `8002`
- 호스트 포트: `8002`
- 헬스체크: `http://<서버>:8002/`
Nginx Proxy Manager 등을 사용한다면 `<서버>:8002`로 프록시 설정.
---
## 로컬 개발 (Windows)
```cmd
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
copy .env.example .env
:: .env 편집
python main.py
```
---
## Gitea 푸시 (Windows)
리포지토리에 변경사항을 올릴 때:
```cmd
push_to_gitea.bat
```
스크립트가 변경사항 확인 → 커밋 메시지 입력 → push 자동 수행.
---
## 주의사항
- `.env`, `cafe24_tokens.json`, `manual-ordering.json`**민감 파일은 절대 Git에 올리지 마세요**.
- `.gitignore`에 자동 제외 설정되어 있습니다.
- DB 이름은 반드시 `orderlist_db`를 사용 (예전 이름 `orderlist_app` 사용 금지).