feat: Docker 및 Docker Compose 배포 지원 추가 (네이티브/도커 하이브리드 지원)

This commit is contained in:
leeyj
2026-04-20 01:22:33 +09:00
parent 379f7eb0c4
commit 6fca65eef1
5 changed files with 134 additions and 2 deletions
+20
View File
@@ -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
+33
View File
@@ -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"]
+34 -2
View File
@@ -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:
+23
View File
@@ -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"
+24
View File
@@ -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`)해야 함.