From 6fca65eef1b0dbf2629acd9c587a2625b668d19e Mon Sep 17 00:00:00 2001 From: leeyj Date: Mon, 20 Apr 2026 01:22:33 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Docker=20=EB=B0=8F=20Docker=20Compose?= =?UTF-8?q?=20=EB=B0=B0=ED=8F=AC=20=EC=A7=80=EC=9B=90=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20(=EB=84=A4=EC=9D=B4=ED=8B=B0=EB=B8=8C/=EB=8F=84=EC=BB=A4=20?= =?UTF-8?q?=ED=95=98=EC=9D=B4=EB=B8=8C=EB=A6=AC=EB=93=9C=20=EC=A7=80?= =?UTF-8?q?=EC=9B=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 20 ++++++++++++++++ Dockerfile | 33 ++++++++++++++++++++++++++ README.md | 36 +++++++++++++++++++++++++++-- docker-compose.yml | 23 ++++++++++++++++++ docs/Bug/20260420_docker_support.md | 24 +++++++++++++++++++ 5 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 docs/Bug/20260420_docker_support.md diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d59a7d6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,20 @@ +.git +.gitignore +__pycache__ +*.pyc +*.pyo +*.pyd +.db +.sqlite3 +data/*.db +logs/*.log +static/uploads/* +.env +Dockerfile +docker-compose.yml +.agent.md +brain_dogfood_stable/ +scratch/ +tools/ +docs/Bug/ +server.pid diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ec6989c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# 1. Base Image +FROM python:3.10-slim + +# 2. Set Environment Variables +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 +ENV PORT=5093 +ENV DEBUG=False + +# 3. Set Working Directory +WORKDIR /app + +# 4. Install System Dependencies (Needed for cryptography and other packages) +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* + +# 5. Install Python Dependencies +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# 6. Copy Project Files +COPY . . + +# 7. Create Necessary Directories +RUN mkdir -p data logs static/uploads + +# 8. Expose Port +EXPOSE 5093 + +# 9. Start Application +CMD ["python", "brain.py"] diff --git a/README.md b/README.md index 9d0edac..62b45c4 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,11 @@ --- -## πŸ› οΈ μ‹œμž‘ν•˜κΈ° +## πŸ› οΈ μ‹œμž‘ν•˜κΈ° (Quick Start) + +μ‚¬μš©μžμ˜ ν™˜κ²½μ— 맞좰 두 κ°€μ§€ 방법 쀑 ν•˜λ‚˜λ₯Ό μ„ νƒν•˜μ—¬ μ‹€ν–‰ν•  수 μžˆμŠ΅λ‹ˆλ‹€. + +### 방법 1: λ„€μ΄ν‹°λΈŒ 직접 μ‹€ν–‰ (ꢌμž₯) ```bash # 1. μ €μž₯μ†Œ 볡제 및 쒅속성 μ„€μΉ˜ @@ -99,6 +103,18 @@ cp .env.example .env python brain.py ``` +### 방법 2: Docker둜 μ‹€ν–‰ (μ»¨ν…Œμ΄λ„ˆ) + +도컀가 μ„€μΉ˜λ˜μ–΄ μžˆλ‹€λ©΄ μ•„λž˜ λͺ…λ Ήμ–΄λ‘œ μ¦‰μ‹œ μ„œλ²„λ₯Ό ꡬ좕할 수 μžˆμŠ΅λ‹ˆλ‹€. + +```bash +# 1. .env μ„€μ • μ™„λ£Œ ν›„ +docker-compose up -d +``` +*λ°μ΄ν„°λ² μ΄μŠ€μ™€ μ—…λ‘œλ“œ νŒŒμΌμ€ 호슀트의 `data/`, `static/uploads/` 디렉토리에 μ•ˆμ „ν•˜κ²Œ μ €μž₯λ©λ‹ˆλ‹€.* + +--- + ## 🌐 접속 방법 μ„œλ²„κ°€ μ‹€ν–‰λ˜λ©΄ λΈŒλΌμš°μ €λ₯Ό 톡해 λ‹€μŒ μ£Όμ†Œλ‘œ 접속할 수 μžˆμŠ΅λ‹ˆλ‹€: @@ -181,9 +197,25 @@ We provide a security model where user data is practically undecipherable. Built --- ### Quick Start + +Choose one of the methods below to launch the server based on your environment. + +#### Method 1: Native Execution (Recommended) + 1. Install dependencies: `pip install -r requirements.txt` 2. Create your `.env` from `.env.example` and update your master credentials. -3. Launch the server: `python brain.py` (Default port: 5050 on Windows, 5093 on Linux). +3. Launch the server: `python brain.py` + +#### Method 2: Docker Deployment (Container) + +If you have Docker installed, you can launch the server instantly: + +```bash +docker-compose up -d +``` +*Your data and uploads are persistently stored in the `data/` and `static/uploads/` directories on the host.* + +--- ### 🌐 How to Access Once the server is running, you can access it via your web browser: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2ab7a09 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.8' + +services: + memo-server: + build: . + container_name: brain-dogfood + restart: always + ports: + - "5093:5093" + env_file: + - .env + volumes: + - ./data:/app/data + - ./static/uploads:/app/static/uploads + - ./logs:/app/logs + - ./config.json:/app/config.json + environment: + - TZ=Asia/Seoul + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" diff --git a/docs/Bug/20260420_docker_support.md b/docs/Bug/20260420_docker_support.md new file mode 100644 index 0000000..7f55387 --- /dev/null +++ b/docs/Bug/20260420_docker_support.md @@ -0,0 +1,24 @@ +# κΈ°λŠ₯ μΆ”κ°€: Docker 및 Docker Compose 배포 지원 + +## 1. κ°œμš” (λ³€κ²½ λ‚΄μš©) +- μ‚¬μš©μžλ“€μ˜ μš”μ²­μ— 따라 μ„œλ²„λ₯Ό μ»¨ν…Œμ΄λ„ˆ ν™˜κ²½μ—μ„œ κ°„νŽΈν•˜κ²Œ 배포할 수 μžˆλ„λ‘ Docker 지원 κΈ°λŠ₯을 좔가함. +- μ‚¬μš©μžκ°€ μ„ ν˜Έν•˜λŠ” λ„€μ΄ν‹°λΈŒ(Native) μ‹€ν–‰ 방식과 도컀(Docker) 방식을 λ™μ‹œμ— μ§€μ›ν•˜λŠ” ν•˜μ΄λΈŒλ¦¬λ“œ ꡬ쑰λ₯Ό 채택함. + +## 2. 쑰치 사항 +- **Dockerfile 생성**: Python 3.10-slim 이미지λ₯Ό 기반으둜 μ„œλ²„ μ‹€ν–‰ ν™˜κ²½ ꡬ좕. +- **docker-compose.yml 생성**: + - DB(`data/`), μ—…λ‘œλ“œ 파일(`static/uploads/`), 둜그(`logs/`), μ„€μ •(`config.json`) λ³Όλ₯¨ 맀핑을 톡해 데이터 μ˜μ†μ„± 확보. + - `.env` 파일 μ£Όμž… μ„€μ • μΆ”κ°€. +- **.dockerignore μΆ”κ°€**: λΆˆν•„μš”ν•œ 파일(DB, 둜그, pycache λ“±)을 λΉŒλ“œ λŒ€μƒμ—μ„œ μ œμ™Έν•˜μ—¬ 이미지 κ²½λŸ‰ν™” 및 λ³΄μ•ˆ κ°•ν™”. +- **README.md κ°€μ΄λ“œ 개편**: + - μ„€μΉ˜ 방법을 'λ„€μ΄ν‹°λΈŒ'와 '도컀' μ„Ήμ…˜μœΌλ‘œ λΆ„λ¦¬ν•˜μ—¬ 가독성 κ°œμ„ . + - μ‚¬μš©μžκ°€ μ„ ν˜Έν•˜λŠ” λ„€μ΄ν‹°λΈŒ 방식을 μ΅œμƒλ‹¨(방법 1)에 μœ μ§€ν•¨. + +## 3. κ²°κ³Ό 및 검증 +- Docker λΉŒλ“œ μ»¨ν…μŠ€νŠΈ ꡬ성 확인. +- λ³Όλ₯¨ 맀핑을 톡해 ν˜ΈμŠ€νŠΈμ™€ μ»¨ν…Œμ΄λ„ˆ κ°„μ˜ 데이터 동기화 ꡬ쑰 섀계 μ™„λ£Œ. +- λ„€μ΄ν‹°λΈŒ μ‹€ν–‰ λ‘œμ§μ— 영ν–₯을 μ£Όμ§€ μ•ŠμœΌλ―€λ‘œ ν•˜μ΄λΈŒλ¦¬λ“œ 지원이 μ •μƒμ μœΌλ‘œ μž‘λ™ν•¨. + +## 4. ν–₯ν›„ 주의 사항 +- λ„μ»€λ‘œ μ‹€ν–‰ν•  경우 호슀트의 파일 κΆŒν•œ(Permission) 문제둜 인해 λ³Όλ₯¨ 마운트된 디렉토리에 μ“°κΈ° κΆŒν•œμ΄ ν•„μš”ν•  수 있음. +- `requirements.txt`κ°€ μ—…λ°μ΄νŠΈλ  경우 Docker 이미지λ₯Ό λ‹€μ‹œ λΉŒλ“œ(`docker-compose build`)ν•΄μ•Ό 함.