KyosukeIchikawa commited on
Commit
3d4a4e7
·
1 Parent(s): 5e96c67

feat: Migrate from Makefile/venv to Dev Container development

Browse files

- Add comprehensive Dev Container configuration for VS Code
- Create Docker-based development environment with all dependencies
- Add VS Code tasks and launch configurations for integrated development
- Update documentation to prioritize Dev Container workflow
- Maintain Makefile compatibility for legacy support
- Add migration guide for developers switching from venv setup

Benefits:
- Zero-setup development environment
- Consistent environment across all developers
- Integrated VS Code debugging and testing
- Docker volume persistence for data and VOICEVOX models
- Automatic dependency and VOICEVOX Core installation

Files added:
- .devcontainer/ - Complete Dev Container setup
- .vscode/ - VS Code tasks and launch configurations
- MIGRATION.md - Migration guide from Makefile/venv
- docker-compose.dev.yml - Alternative docker-compose setup

.devcontainer/Dockerfile ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Development container for Yomitalk
2
+ FROM python:3.11-slim
3
+
4
+ # Install system dependencies
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ git \
7
+ curl \
8
+ wget \
9
+ make \
10
+ build-essential \
11
+ ffmpeg \
12
+ sudo \
13
+ # For playwright browsers
14
+ libnss3 \
15
+ libatk-bridge2.0-0 \
16
+ libdrm2 \
17
+ libxkbcommon0 \
18
+ libgtk-3-0 \
19
+ libgbm1 \
20
+ libasound2 \
21
+ # For VS Code development
22
+ ca-certificates \
23
+ gnupg \
24
+ lsb-release \
25
+ && rm -rf /var/lib/apt/lists/*
26
+
27
+ # Create vscode user for development
28
+ RUN groupadd --gid 1000 vscode \
29
+ && useradd --uid 1000 --gid vscode --shell /bin/bash --create-home vscode \
30
+ && echo 'vscode ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
31
+
32
+ # Set up working directory
33
+ WORKDIR /workspace
34
+
35
+ # Install Python development tools globally (no venv needed in container)
36
+ COPY requirements.in requirements-lint.txt ./
37
+ RUN pip install --upgrade pip && \
38
+ pip install --timeout 600 --retries 5 torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu && \
39
+ pip install --timeout 300 --retries 3 -r requirements-lint.txt
40
+
41
+ # Install pip-tools for requirements management
42
+ RUN pip install pip-tools
43
+
44
+ # Switch to vscode user
45
+ USER vscode
46
+
47
+ # Set environment variables for development
48
+ ENV PYTHONPATH=/workspace
49
+ ENV VOICEVOX_ACCEPT_AGREEMENT=true
50
+ ENV PAGER=cat
51
+ ENV LESSCHARSET=utf-8
52
+
53
+ # Default command (will be overridden by devcontainer)
54
+ CMD ["sleep", "infinity"]
.devcontainer/README.md ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Yomitalk Development Container
2
+
3
+ This directory contains the development container configuration for Yomitalk, enabling a consistent and reproducible development environment using VS Code Dev Containers.
4
+
5
+ ## Quick Start
6
+
7
+ ### Prerequisites
8
+
9
+ - [Docker](https://docs.docker.com/get-docker/)
10
+ - [VS Code](https://code.visualstudio.com/)
11
+ - [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
12
+
13
+ ### Getting Started
14
+
15
+ 1. **Clone the repository:**
16
+ ```bash
17
+ git clone <repository-url>
18
+ cd yomitalk
19
+ ```
20
+
21
+ 2. **Open in VS Code:**
22
+ ```bash
23
+ code .
24
+ ```
25
+
26
+ 3. **Open in Dev Container:**
27
+ - Press `F1` and select "Dev Containers: Reopen in Container"
28
+ - Or click the popup notification to reopen in container
29
+ - Wait for the container to build and setup to complete
30
+
31
+ 4. **Start developing:**
32
+ - The environment will be automatically configured
33
+ - VOICEVOX Core will be downloaded and installed
34
+ - All Python dependencies will be installed
35
+ - Pre-commit hooks will be configured
36
+
37
+ ## Development Workflow
38
+
39
+ ### Running the Application
40
+
41
+ ```bash
42
+ # Run the Yomitalk web application
43
+ python app.py
44
+
45
+ # Or use VS Code task (Ctrl+Shift+P -> "Tasks: Run Task" -> "Run Yomitalk App")
46
+ ```
47
+
48
+ The application will be available at `http://localhost:7860`
49
+
50
+ ### Testing
51
+
52
+ ```bash
53
+ # Run all tests
54
+ pytest tests/
55
+
56
+ # Run unit tests only
57
+ pytest tests/unit/
58
+
59
+ # Run E2E tests only
60
+ E2E_TEST_MODE=true pytest tests/e2e/
61
+
62
+ # Use VS Code tasks for better integration
63
+ ```
64
+
65
+ ### Code Quality
66
+
67
+ ```bash
68
+ # Format code
69
+ black . && isort .
70
+
71
+ # Run linting
72
+ flake8 . && mypy .
73
+
74
+ # Run pre-commit hooks
75
+ pre-commit run --all-files
76
+ ```
77
+
78
+ ### Common Commands
79
+
80
+ | Task | Command | VS Code Task |
81
+ |------|---------|-------------|
82
+ | Run app | `python app.py` | "Run Yomitalk App" |
83
+ | All tests | `pytest tests/` | "Run All Tests" |
84
+ | Unit tests | `pytest tests/unit/` | "Run Unit Tests" |
85
+ | E2E tests | `E2E_TEST_MODE=true pytest tests/e2e/` | "Run E2E Tests" |
86
+ | Format | `black . && isort .` | "Format Code" |
87
+ | Lint | `flake8 . && mypy .` | "Run Linting" |
88
+ | Pre-commit | `pre-commit run --all-files` | "Run Pre-commit" |
89
+
90
+ ## Container Architecture
91
+
92
+ ### Base Image
93
+ - **Python 3.11 slim**: Official Python image for consistent Python environment
94
+ - **System packages**: FFmpeg, build tools, and browser dependencies for Playwright
95
+
96
+ ### Development Features
97
+ - **Non-root user**: `vscode` user for security and VS Code integration
98
+ - **Persistent volumes**: Separate volumes for data and VOICEVOX models
99
+ - **Port forwarding**: Automatic port 7860 forwarding for web access
100
+ - **Extensions**: Pre-configured VS Code extensions for Python development
101
+
102
+ ### File Structure
103
+
104
+ ```
105
+ .devcontainer/
106
+ ├── devcontainer.json # Main configuration file
107
+ ├── docker-compose.yml # Multi-service container setup
108
+ ├── Dockerfile # Development container image
109
+ ├── setup.sh # Post-creation setup script
110
+ └── README.md # This file
111
+ ```
112
+
113
+ ## Customization
114
+
115
+ ### Adding Extensions
116
+
117
+ Edit `.devcontainer/devcontainer.json`:
118
+
119
+ ```json
120
+ {
121
+ "customizations": {
122
+ "vscode": {
123
+ "extensions": [
124
+ "existing-extensions...",
125
+ "new.extension.id"
126
+ ]
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ ### Environment Variables
133
+
134
+ Add to `containerEnv` in `devcontainer.json`:
135
+
136
+ ```json
137
+ {
138
+ "containerEnv": {
139
+ "NEW_VAR": "value"
140
+ }
141
+ }
142
+ ```
143
+
144
+ ### System Packages
145
+
146
+ Edit `.devcontainer/Dockerfile` and add to the `RUN apt-get install` command.
147
+
148
+ ## Troubleshooting
149
+
150
+ ### Container Build Issues
151
+
152
+ 1. **Clean rebuild:**
153
+ ```bash
154
+ # Remove container and rebuild
155
+ # In VS Code: "Dev Containers: Rebuild Container"
156
+ ```
157
+
158
+ 2. **VOICEVOX download fails:**
159
+ ```bash
160
+ # Manually run setup in container terminal
161
+ bash .devcontainer/setup.sh
162
+ ```
163
+
164
+ 3. **Permission issues:**
165
+ ```bash
166
+ # Fix ownership (run in container terminal)
167
+ sudo chown -R vscode:vscode /workspace
168
+ ```
169
+
170
+ ### Performance Issues
171
+
172
+ 1. **Slow file access:**
173
+ - Ensure using volume mounts for large directories (data, voicevox_core)
174
+ - Check Docker Desktop resource allocation
175
+
176
+ 2. **Memory issues:**
177
+ - Increase Docker Desktop memory limit
178
+ - VOICEVOX and ML models require significant RAM
179
+
180
+ ### Network Issues
181
+
182
+ 1. **Port forwarding not working:**
183
+ - Check VS Code port forwarding tab
184
+ - Ensure application binds to `0.0.0.0:7860`, not `localhost:7860`
185
+
186
+ 2. **Internet access for downloads:**
187
+ - Check Docker network configuration
188
+ - Verify proxy settings if behind corporate firewall
189
+
190
+ ## Migration from Makefile/venv
191
+
192
+ ### Key Changes
193
+
194
+ - **No virtual environment**: Python packages installed globally in container
195
+ - **No make commands**: Use VS Code tasks or direct commands
196
+ - **Persistent data**: Data and models stored in Docker volumes
197
+ - **Integrated tools**: Linting, formatting, and testing integrated with VS Code
198
+
199
+ ### Old vs New Commands
200
+
201
+ | Old (Makefile) | New (Devcontainer) |
202
+ |----------------|-------------------|
203
+ | `make setup` | Automatic via `postCreateCommand` |
204
+ | `make run` | `python app.py` or VS Code task |
205
+ | `make test` | `pytest tests/` or VS Code task |
206
+ | `make lint` | `flake8 . && mypy .` or VS Code task |
207
+ | `make format` | `black . && isort .` or VS Code task |
208
+ | `make clean` | "Dev Containers: Rebuild Container" |
209
+
210
+ ## Benefits
211
+
212
+ ### Developer Experience
213
+ - **Zero setup**: One-click development environment
214
+ - **Consistency**: Same environment across all developers
215
+ - **Isolation**: No conflicts with host system packages
216
+ - **Integration**: Deep VS Code integration with debugging, testing, and formatting
217
+
218
+ ### CI/CD Alignment
219
+ - **Same base**: Development and production environments share base image
220
+ - **Reproducible**: Exact same dependencies and versions
221
+ - **Testable**: E2E tests run in similar environment to production
.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Yomitalk Development Environment",
3
+ "dockerComposeFile": "docker-compose.yml",
4
+ "service": "yomitalk-dev",
5
+ "workspaceFolder": "/workspace",
6
+ "shutdownAction": "stopCompose",
7
+
8
+ // Features to add to the dev container. More info: https://containers.dev/features.
9
+ "features": {
10
+ "ghcr.io/devcontainers/features/git:1": {
11
+ "version": "latest",
12
+ "ppa": true
13
+ },
14
+ "ghcr.io/devcontainers/features/github-cli:1": {
15
+ "version": "latest"
16
+ }
17
+ },
18
+
19
+ // Configure tool-specific properties.
20
+ "customizations": {
21
+ "vscode": {
22
+ "settings": {
23
+ "python.defaultInterpreterPath": "/usr/local/bin/python",
24
+ "python.terminal.activateEnvironment": false,
25
+ "python.linting.enabled": true,
26
+ "python.linting.pylintEnabled": false,
27
+ "python.linting.flake8Enabled": true,
28
+ "python.linting.mypyEnabled": true,
29
+ "python.formatting.provider": "black",
30
+ "python.sortImports.provider": "isort",
31
+ "python.testing.pytestEnabled": true,
32
+ "python.testing.pytestArgs": [
33
+ "tests/"
34
+ ],
35
+ "editor.formatOnSave": true,
36
+ "editor.codeActionsOnSave": {
37
+ "source.organizeImports": true
38
+ },
39
+ "files.exclude": {
40
+ "**/__pycache__": true,
41
+ "**/.pytest_cache": true,
42
+ "**/data/temp": true,
43
+ "**/data/output": true,
44
+ "**/voicevox_core": true
45
+ },
46
+ "git.enableCommitSigning": false,
47
+ "terminal.integrated.defaultProfile.linux": "bash"
48
+ },
49
+ "extensions": [
50
+ "ms-python.python",
51
+ "ms-python.flake8",
52
+ "ms-python.mypy-type-checker",
53
+ "ms-python.black-formatter",
54
+ "ms-python.isort",
55
+ "ms-toolsai.jupyter",
56
+ "wholroyd.jinja",
57
+ "redhat.vscode-yaml",
58
+ "ms-vscode.makefile-tools",
59
+ "GitHub.copilot",
60
+ "GitHub.copilot-chat",
61
+ "ms-playwright.playwright",
62
+ "ms-vscode.test-adapter-converter",
63
+ "littlefoxteam.vscode-python-test-adapter",
64
+ "streetsidesoftware.code-spell-checker"
65
+ ]
66
+ }
67
+ },
68
+
69
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
70
+ "forwardPorts": [7860],
71
+ "portsAttributes": {
72
+ "7860": {
73
+ "label": "Yomitalk Web App",
74
+ "onAutoForward": "notify"
75
+ }
76
+ },
77
+
78
+ // Use 'postCreateCommand' to run commands after the container is created.
79
+ "postCreateCommand": "bash .devcontainer/setup.sh",
80
+
81
+ // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
82
+ "remoteUser": "vscode",
83
+
84
+ // Environment variables
85
+ "containerEnv": {
86
+ "VOICEVOX_ACCEPT_AGREEMENT": "true",
87
+ "PAGER": "cat",
88
+ "LESSCHARSET": "utf-8",
89
+ "E2E_TEST_MODE": "false"
90
+ },
91
+
92
+ // Mounts for persistent data
93
+ "mounts": [
94
+ "source=yomitalk-data,target=/workspace/data,type=volume",
95
+ "source=yomitalk-voicevox,target=/workspace/voicevox_core,type=volume"
96
+ ]
97
+ }
.devcontainer/docker-compose.yml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ yomitalk-dev:
5
+ build:
6
+ context: ..
7
+ dockerfile: .devcontainer/Dockerfile
8
+ volumes:
9
+ - ..:/workspace:cached
10
+ - yomitalk-data:/workspace/data
11
+ - yomitalk-voicevox:/workspace/voicevox_core
12
+ environment:
13
+ - VOICEVOX_ACCEPT_AGREEMENT=true
14
+ - PAGER=cat
15
+ - LESSCHARSET=utf-8
16
+ - E2E_TEST_MODE=false
17
+ ports:
18
+ - "7860:7860"
19
+ # Keep container running for development
20
+ command: sleep infinity
21
+ # Add capabilities for audio processing if needed
22
+ cap_add:
23
+ - SYS_PTRACE
24
+ security_opt:
25
+ - seccomp:unconfined
26
+
27
+ volumes:
28
+ yomitalk-data:
29
+ yomitalk-voicevox:
.devcontainer/setup.sh ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Post-create setup script for Yomitalk devcontainer
4
+ set -e
5
+
6
+ echo "🚀 Setting up Yomitalk development environment..."
7
+
8
+ # Install Python dependencies
9
+ echo "📦 Installing Python dependencies..."
10
+ pip install --timeout 300 --retries 3 -r requirements.txt
11
+
12
+ # Install VOICEVOX Core if not already present
13
+ if [ ! -d "voicevox_core" ] || [ -z "$(ls -A voicevox_core 2>/dev/null)" ]; then
14
+ echo "🎤 Setting up VOICEVOX Core..."
15
+ chmod +x scripts/download_voicevox.sh
16
+ scripts/download_voicevox.sh \
17
+ --version 0.16.0 \
18
+ --dir voicevox_core \
19
+ --skip-if-exists \
20
+ --accept-agreement
21
+ fi
22
+
23
+ # Install VOICEVOX Core Python module
24
+ echo "🐍 Installing VOICEVOX Core Python module..."
25
+ OS_TYPE="manylinux_2_34_x86_64"
26
+ VOICEVOX_VERSION="0.16.0"
27
+ WHEEL_URL="https://github.com/VOICEVOX/voicevox_core/releases/download/${VOICEVOX_VERSION}/voicevox_core-${VOICEVOX_VERSION}-cp310-abi3-${OS_TYPE}.whl"
28
+ pip install "${WHEEL_URL}" || echo "⚠️ Warning: Failed to install VOICEVOX Core wheel. You may need to install it manually."
29
+
30
+ # Install playwright browsers for E2E testing
31
+ echo "🎭 Installing Playwright browsers for E2E testing..."
32
+ playwright install || echo "⚠️ Warning: Failed to install Playwright browsers."
33
+
34
+ # Set up pre-commit hooks
35
+ echo "🔧 Setting up pre-commit hooks..."
36
+ pre-commit install || echo "⚠️ Warning: Failed to install pre-commit hooks."
37
+
38
+ # Create necessary directories with proper permissions
39
+ echo "📁 Creating data directories..."
40
+ mkdir -p data/temp data/output data/logs
41
+ chmod -R 755 data
42
+
43
+ # Ensure git configuration
44
+ echo "⚙️ Configuring git..."
45
+ git config --global --add safe.directory /workspace
46
+
47
+ echo "✅ Yomitalk development environment setup complete!"
48
+ echo ""
49
+ echo "🎯 Quick start commands:"
50
+ echo " • Run app: python app.py"
51
+ echo " • Run tests: pytest tests/"
52
+ echo " • Run unit tests: pytest tests/unit/"
53
+ echo " • Run E2E tests: E2E_TEST_MODE=true pytest tests/e2e/"
54
+ echo " • Format code: black . && isort ."
55
+ echo " • Run linting: flake8 . && mypy ."
56
+ echo " • Run pre-commit: pre-commit run --all-files"
57
+ echo ""
.gitignore CHANGED
@@ -17,16 +17,22 @@ __pycache__/
17
  venv/
18
  ENV/
19
 
20
- # IDE
21
  .idea/
22
- .vscode/
23
  *.swp
24
  *.swo
25
- .vscode/settings.json
 
 
26
 
27
  # Project specific
28
  data/temp/*
29
  data/output/*
 
 
 
 
30
  voicevox_core/
31
  *.log
32
  .env
@@ -37,20 +43,6 @@ voicevox_core/
37
  htmlcov/
38
  tests/e2e/screenshots/
39
 
40
- # データ・キャッシュディレクトリ
41
- data/temp/*
42
- data/output/*
43
- data/logs/*
44
- !data/temp/.gitkeep
45
- !data/output/.gitkeep
46
- !data/logs/.gitkeep
47
-
48
- # IDE関連
49
- .idea/
50
- .vscode/
51
- *.swp
52
- *.swo
53
-
54
  # システム関連
55
  .DS_Store
56
  Thumbs.db
@@ -60,8 +52,5 @@ build/
60
  dist/
61
  *.spec
62
 
63
- # VOICEVOX Core
64
- voicevox_core/
65
-
66
  # その他の一時ファイル
67
  *.png
 
17
  venv/
18
  ENV/
19
 
20
+ # IDE関連
21
  .idea/
22
+ .vscode/settings.json # User-specific settings only
23
  *.swp
24
  *.swo
25
+
26
+ # Dev Container
27
+ .devcontainer/.env
28
 
29
  # Project specific
30
  data/temp/*
31
  data/output/*
32
+ data/logs/*
33
+ !data/temp/.gitkeep
34
+ !data/output/.gitkeep
35
+ !data/logs/.gitkeep
36
  voicevox_core/
37
  *.log
38
  .env
 
43
  htmlcov/
44
  tests/e2e/screenshots/
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  # システム関連
47
  .DS_Store
48
  Thumbs.db
 
52
  dist/
53
  *.spec
54
 
 
 
 
55
  # その他の一時ファイル
56
  *.png
.vscode/launch.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Run Yomitalk App",
6
+ "type": "python",
7
+ "request": "launch",
8
+ "program": "app.py",
9
+ "console": "integratedTerminal",
10
+ "cwd": "${workspaceFolder}",
11
+ "env": {
12
+ "PYTHONPATH": "${workspaceFolder}",
13
+ "VOICEVOX_ACCEPT_AGREEMENT": "true"
14
+ },
15
+ "args": ["--debug"]
16
+ },
17
+ {
18
+ "name": "Debug Unit Tests",
19
+ "type": "python",
20
+ "request": "launch",
21
+ "module": "pytest",
22
+ "args": ["tests/unit/", "-v", "--tb=short"],
23
+ "console": "integratedTerminal",
24
+ "cwd": "${workspaceFolder}",
25
+ "env": {
26
+ "PYTHONPATH": "${workspaceFolder}"
27
+ }
28
+ },
29
+ {
30
+ "name": "Debug E2E Tests",
31
+ "type": "python",
32
+ "request": "launch",
33
+ "module": "pytest",
34
+ "args": ["tests/e2e/", "-v", "--tb=short"],
35
+ "console": "integratedTerminal",
36
+ "cwd": "${workspaceFolder}",
37
+ "env": {
38
+ "PYTHONPATH": "${workspaceFolder}",
39
+ "E2E_TEST_MODE": "true"
40
+ }
41
+ },
42
+ {
43
+ "name": "Debug Current Test File",
44
+ "type": "python",
45
+ "request": "launch",
46
+ "module": "pytest",
47
+ "args": ["${file}", "-v", "--tb=short"],
48
+ "console": "integratedTerminal",
49
+ "cwd": "${workspaceFolder}",
50
+ "env": {
51
+ "PYTHONPATH": "${workspaceFolder}"
52
+ }
53
+ }
54
+ ]
55
+ }
.vscode/settings.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "makefile.configureOnOpen": false
3
+ }
.vscode/tasks.json ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "label": "Run Yomitalk App",
6
+ "type": "shell",
7
+ "command": "python",
8
+ "args": ["app.py"],
9
+ "group": {
10
+ "kind": "build",
11
+ "isDefault": true
12
+ },
13
+ "presentation": {
14
+ "echo": true,
15
+ "reveal": "always",
16
+ "focus": false,
17
+ "panel": "new"
18
+ },
19
+ "problemMatcher": []
20
+ },
21
+ {
22
+ "label": "Run All Tests",
23
+ "type": "shell",
24
+ "command": "pytest",
25
+ "args": ["tests/", "--durations=10"],
26
+ "group": "test",
27
+ "presentation": {
28
+ "echo": true,
29
+ "reveal": "always",
30
+ "focus": false,
31
+ "panel": "new"
32
+ },
33
+ "problemMatcher": []
34
+ },
35
+ {
36
+ "label": "Run Unit Tests",
37
+ "type": "shell",
38
+ "command": "pytest",
39
+ "args": ["tests/unit/", "--durations=10"],
40
+ "group": "test",
41
+ "presentation": {
42
+ "echo": true,
43
+ "reveal": "always",
44
+ "focus": false,
45
+ "panel": "new"
46
+ },
47
+ "problemMatcher": []
48
+ },
49
+ {
50
+ "label": "Run E2E Tests",
51
+ "type": "shell",
52
+ "command": "pytest",
53
+ "args": ["tests/e2e/", "--durations=10"],
54
+ "group": "test",
55
+ "env": {
56
+ "E2E_TEST_MODE": "true"
57
+ },
58
+ "presentation": {
59
+ "echo": true,
60
+ "reveal": "always",
61
+ "focus": false,
62
+ "panel": "new"
63
+ },
64
+ "problemMatcher": []
65
+ },
66
+ {
67
+ "label": "Format Code",
68
+ "type": "shell",
69
+ "command": "bash",
70
+ "args": ["-c", "black . && isort . && autoflake --in-place --remove-unused-variables --remove-all-unused-imports --recursive ."],
71
+ "group": "build",
72
+ "presentation": {
73
+ "echo": true,
74
+ "reveal": "always",
75
+ "focus": false,
76
+ "panel": "new"
77
+ },
78
+ "problemMatcher": []
79
+ },
80
+ {
81
+ "label": "Run Linting",
82
+ "type": "shell",
83
+ "command": "bash",
84
+ "args": ["-c", "flake8 . && mypy ."],
85
+ "group": "test",
86
+ "presentation": {
87
+ "echo": true,
88
+ "reveal": "always",
89
+ "focus": false,
90
+ "panel": "new"
91
+ },
92
+ "problemMatcher": [
93
+ "$flake8",
94
+ "$mypy-python"
95
+ ]
96
+ },
97
+ {
98
+ "label": "Run Pre-commit",
99
+ "type": "shell",
100
+ "command": "pre-commit",
101
+ "args": ["run", "--all-files"],
102
+ "group": "test",
103
+ "presentation": {
104
+ "echo": true,
105
+ "reveal": "always",
106
+ "focus": false,
107
+ "panel": "new"
108
+ },
109
+ "problemMatcher": []
110
+ },
111
+ {
112
+ "label": "Compile Requirements",
113
+ "type": "shell",
114
+ "command": "pip-compile",
115
+ "args": ["-v", "requirements.in"],
116
+ "group": "build",
117
+ "presentation": {
118
+ "echo": true,
119
+ "reveal": "always",
120
+ "focus": false,
121
+ "panel": "new"
122
+ },
123
+ "problemMatcher": []
124
+ },
125
+ {
126
+ "label": "Install VOICEVOX Core",
127
+ "type": "shell",
128
+ "command": "bash",
129
+ "args": ["scripts/download_voicevox.sh", "--version", "0.16.0", "--dir", "voicevox_core", "--accept-agreement"],
130
+ "group": "build",
131
+ "presentation": {
132
+ "echo": true,
133
+ "reveal": "always",
134
+ "focus": false,
135
+ "panel": "new"
136
+ },
137
+ "problemMatcher": []
138
+ }
139
+ ]
140
+ }
CLAUDE.md CHANGED
@@ -12,35 +12,55 @@ Before working on this codebase, **read [docs/design.md](docs/design.md)** for c
12
 
13
  ## Essential Commands
14
 
15
- ### Setup and Environment
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  ```bash
 
17
  make setup # Complete setup: deps, VOICEVOX, lint tools, pre-commit
18
  make venv # Create virtual environment only
19
  make install # Install Python packages only
20
  make download-voicevox-core # Download VOICEVOX Core for audio generation
21
- ```
22
 
23
- ### Development
24
- ```bash
25
  make run # Start the Gradio application on port 7860
26
  make lint # Run flake8 and mypy static analysis
27
  make format # Auto-format code with black, isort, autoflake, autopep8
28
- ```
29
 
30
- ### Testing
31
- ```bash
32
  make test # Run all tests (unit + E2E)
33
  make test-unit # Run unit tests only
34
  make test-e2e # Run E2E tests (sets E2E_TEST_MODE=true)
35
  make test-staged # Run tests only for staged files
36
- ```
37
 
38
- ### Pre-commit Hooks
39
- ```bash
40
  make pre-commit-install # Install pre-commit hooks
41
  make pre-commit-run # Run pre-commit hooks manually
42
  ```
43
 
 
 
44
  ## Architecture Overview
45
 
46
  **📋 For detailed architecture information, see [docs/design.md](docs/design.md)**
 
12
 
13
  ## Essential Commands
14
 
15
+ ### Dev Container Setup (Recommended)
16
+
17
+ **Open in VS Code Dev Container:**
18
+ - Press `F1` → "Dev Containers: Reopen in Container"
19
+ - Automatic setup: dependencies, VOICEVOX Core, pre-commit hooks
20
+
21
+ **Development Commands:**
22
+ ```bash
23
+ python app.py # Start the Gradio application on port 7860
24
+ pytest tests/ # Run all tests (unit + E2E)
25
+ pytest tests/unit/ # Run unit tests only
26
+ E2E_TEST_MODE=true pytest tests/e2e/ # Run E2E tests
27
+ flake8 . && mypy . # Run static analysis
28
+ black . && isort . # Auto-format code
29
+ pre-commit run --all-files # Run pre-commit hooks manually
30
+ ```
31
+
32
+ **VS Code Integration:** Use `Ctrl+Shift+P` → "Tasks: Run Task" for GUI access to all commands
33
+
34
+ ### Traditional Setup (Legacy)
35
+
36
+ <details>
37
+ <summary>Makefile/venv commands (still supported)</summary>
38
+
39
  ```bash
40
+ # Setup and Environment
41
  make setup # Complete setup: deps, VOICEVOX, lint tools, pre-commit
42
  make venv # Create virtual environment only
43
  make install # Install Python packages only
44
  make download-voicevox-core # Download VOICEVOX Core for audio generation
 
45
 
46
+ # Development
 
47
  make run # Start the Gradio application on port 7860
48
  make lint # Run flake8 and mypy static analysis
49
  make format # Auto-format code with black, isort, autoflake, autopep8
 
50
 
51
+ # Testing
 
52
  make test # Run all tests (unit + E2E)
53
  make test-unit # Run unit tests only
54
  make test-e2e # Run E2E tests (sets E2E_TEST_MODE=true)
55
  make test-staged # Run tests only for staged files
 
56
 
57
+ # Pre-commit Hooks
 
58
  make pre-commit-install # Install pre-commit hooks
59
  make pre-commit-run # Run pre-commit hooks manually
60
  ```
61
 
62
+ </details>
63
+
64
  ## Architecture Overview
65
 
66
  **📋 For detailed architecture information, see [docs/design.md](docs/design.md)**
MIGRATION.md ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Migration Guide: Makefile/venv → Dev Containers
2
+
3
+ This guide helps you migrate from the traditional Makefile/venv setup to the new Dev Container development environment.
4
+
5
+ ## Why Migrate?
6
+
7
+ ### Benefits of Dev Containers
8
+ - **Zero setup**: One-click development environment
9
+ - **Consistency**: Same environment across all developers and CI/CD
10
+ - **Isolation**: No conflicts with host system packages
11
+ - **VS Code integration**: Seamless debugging, testing, and development tools
12
+ - **Docker alignment**: Development environment matches production container
13
+
14
+ ### Before (Makefile/venv)
15
+ ```bash
16
+ make setup # Manual setup required
17
+ source venv/bin/activate # Manual activation
18
+ make run # Run commands
19
+ ```
20
+
21
+ ### After (Dev Container)
22
+ ```bash
23
+ # Just open in VS Code and reopen in container
24
+ # Everything is automatic!
25
+ python app.py # Direct commands
26
+ ```
27
+
28
+ ## Migration Steps
29
+
30
+ ### 1. Prerequisites
31
+
32
+ Install required tools:
33
+ - [Docker](https://docs.docker.com/get-docker/)
34
+ - [VS Code](https://code.visualstudio.com/)
35
+ - [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
36
+
37
+ ### 2. Clean Up Old Environment (Optional)
38
+
39
+ If you want to start fresh:
40
+
41
+ ```bash
42
+ # Clean up old virtual environment and generated files
43
+ make clean
44
+
45
+ # Or manually:
46
+ rm -rf venv/
47
+ rm -rf data/temp/* data/output/*
48
+ rm -rf __pycache__ .pytest_cache
49
+ ```
50
+
51
+ ### 3. Open in Dev Container
52
+
53
+ 1. **Open VS Code:**
54
+ ```bash
55
+ code .
56
+ ```
57
+
58
+ 2. **Reopen in Container:**
59
+ - Press `F1`
60
+ - Type "Dev Containers: Reopen in Container"
61
+ - Select the command
62
+ - Wait for container to build and setup to complete
63
+
64
+ 3. **First-time setup:**
65
+ - Container builds automatically (5-10 minutes first time)
66
+ - VOICEVOX Core downloads automatically
67
+ - All dependencies install automatically
68
+ - Pre-commit hooks setup automatically
69
+
70
+ ### 4. Verify Setup
71
+
72
+ Test that everything works:
73
+
74
+ ```bash
75
+ # Run the application
76
+ python app.py
77
+
78
+ # Run tests
79
+ pytest tests/
80
+
81
+ # Check linting
82
+ flake8 . && mypy .
83
+ ```
84
+
85
+ ### 5. Update Your Workflow
86
+
87
+ #### Old Workflow
88
+ ```bash
89
+ source venv/bin/activate # Activate environment
90
+ make run # Run application
91
+ make test # Run tests
92
+ make lint # Run linting
93
+ make format # Format code
94
+ deactivate # Deactivate environment
95
+ ```
96
+
97
+ #### New Workflow
98
+ ```bash
99
+ # No activation needed - just use commands directly
100
+ python app.py # Run application
101
+ pytest tests/ # Run tests
102
+ flake8 . && mypy . # Run linting
103
+ black . && isort . # Format code
104
+
105
+ # Or use VS Code tasks:
106
+ # Ctrl+Shift+P → "Tasks: Run Task" → Select task
107
+ ```
108
+
109
+ ## Command Mapping
110
+
111
+ | Old (Make) | New (Direct) | VS Code Task |
112
+ |------------|--------------|-------------|
113
+ | `make setup` | Automatic via devcontainer | N/A |
114
+ | `make run` | `python app.py` | "Run Yomitalk App" |
115
+ | `make test` | `pytest tests/` | "Run All Tests" |
116
+ | `make test-unit` | `pytest tests/unit/` | "Run Unit Tests" |
117
+ | `make test-e2e` | `E2E_TEST_MODE=true pytest tests/e2e/` | "Run E2E Tests" |
118
+ | `make lint` | `flake8 . && mypy .` | "Run Linting" |
119
+ | `make format` | `black . && isort .` | "Format Code" |
120
+ | `make pre-commit-run` | `pre-commit run --all-files` | "Run Pre-commit" |
121
+ | `make clean` | "Dev Containers: Rebuild Container" | N/A |
122
+
123
+ ## VS Code Integration
124
+
125
+ ### Tasks
126
+ Access via `Ctrl+Shift+P` → "Tasks: Run Task":
127
+ - Run Yomitalk App
128
+ - Run All Tests
129
+ - Run Unit Tests
130
+ - Run E2E Tests
131
+ - Format Code
132
+ - Run Linting
133
+ - Run Pre-commit
134
+
135
+ ### Debugging
136
+ - **F5**: Debug current configuration
137
+ - **Ctrl+F5**: Run without debugging
138
+ - Configurations available for app, unit tests, E2E tests
139
+
140
+ ### Extensions
141
+ Automatically installed and configured:
142
+ - Python
143
+ - Black Formatter
144
+ - isort
145
+ - Flake8
146
+ - MyPy Type Checker
147
+ - Jupyter
148
+ - Jinja
149
+ - Playwright
150
+
151
+ ## Troubleshooting
152
+
153
+ ### Container Won't Start
154
+ 1. Ensure Docker is running
155
+ 2. Check Docker Desktop has enough resources (4GB+ RAM recommended)
156
+ 3. Try "Dev Containers: Rebuild Container"
157
+
158
+ ### VOICEVOX Download Fails
159
+ ```bash
160
+ # Run setup script manually in container terminal
161
+ bash .devcontainer/setup.sh
162
+ ```
163
+
164
+ ### Port 7860 Not Accessible
165
+ 1. Check VS Code port forwarding tab
166
+ 2. Ensure app binds to `0.0.0.0:7860`, not `localhost:7860`
167
+ 3. Check firewall settings
168
+
169
+ ### Slow Performance
170
+ 1. Use Docker volumes for large directories (already configured)
171
+ 2. Increase Docker Desktop resource allocation
172
+ 3. Consider using WSL2 backend on Windows
173
+
174
+ ### Permission Issues
175
+ ```bash
176
+ # In container terminal
177
+ sudo chown -R vscode:vscode /workspace
178
+ ```
179
+
180
+ ## Keeping Both Approaches
181
+
182
+ You can use both approaches simultaneously:
183
+
184
+ ### Dev Container (Recommended)
185
+ - Daily development
186
+ - Debugging and testing
187
+ - Code review and collaboration
188
+
189
+ ### Makefile (Backup)
190
+ - CI/CD environments without container support
191
+ - Quick local testing
192
+ - Legacy system compatibility
193
+
194
+ The Makefile is still maintained and functional for those who prefer it or need it for specific scenarios.
195
+
196
+ ## Getting Help
197
+
198
+ - **Dev Container Issues**: See `.devcontainer/README.md`
199
+ - **Application Issues**: See main `README.md`
200
+ - **Architecture Questions**: See `docs/design.md`
201
+ - **Development Guidelines**: See `CLAUDE.md`
202
+
203
+ ## Benefits You'll Notice
204
+
205
+ ### Immediate
206
+ - No more virtual environment management
207
+ - Consistent Python environment
208
+ - Pre-configured development tools
209
+ - Integrated VS Code experience
210
+
211
+ ### Long-term
212
+ - Same environment across team members
213
+ - Easier onboarding for new developers
214
+ - Better CI/CD environment alignment
215
+ - Simplified Docker deployment
README.md CHANGED
@@ -31,37 +31,61 @@ short_description: ドキュメントからポッドキャスト風の解説音
31
 
32
  ## 必要条件
33
 
34
- - Python 3.11以上
 
 
35
  - OpenAI API キー または Google Gemini API キー
36
- - VOICEVOX Core (音声生成に必要)
37
 
38
- ## インスール方法
39
 
40
- 1. リポジトリクローン:
41
- ```
 
 
42
  git clone https://github.com/yourusername/yomitalk.git
43
  cd yomitalk
44
  ```
45
 
46
- 2. 環境構築
47
- ```
48
- make setup
49
  ```
50
 
51
- 下記等が実行されます
52
- - 仮想環境の作成
53
- - 依存パケージインストール
54
- - VOICEVOX Coreのダウンロード
55
- - pre-commitの設定
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  ## 使い方
58
 
59
- 1. アプリケーションを起動:
60
- ```
61
  python app.py
62
  ```
63
 
64
- 2. ブラウザで `http://localhost:7860` にアクセス
65
 
66
  3. ドキュメント(PDF、テキストファイルなど)をアップロードしてテキストを抽出
67
 
@@ -81,6 +105,33 @@ short_description: ドキュメントからポッドキャスト風の解説音
81
 
82
  11. 生成された音声を再生またはダウンロード
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  ## APIキーの取得方法
85
 
86
  ### OpenAI APIキー
 
31
 
32
  ## 必要条件
33
 
34
+ - [Docker](https://docs.docker.com/get-docker/)
35
+ - [VS Code](https://code.visualstudio.com/) (開発時)
36
+ - [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) (開発時)
37
  - OpenAI API キー または Google Gemini API キー
 
38
 
39
+ ## 開発環境セッアップ(推奨)
40
 
41
+ ### Dev Containers 使用(推奨)
42
+
43
+ 1. **リポジトリをクローン:**
44
+ ```bash
45
  git clone https://github.com/yourusername/yomitalk.git
46
  cd yomitalk
47
  ```
48
 
49
+ 2. **VS Code で開く:**
50
+ ```bash
51
+ code .
52
  ```
53
 
54
+ 3. **Dev Container で開く:**
55
+ - `F1` を押して "Dev Containers: Reopen in Container" を選択
56
+ - または通知ポプアップ "Reopen in Container" をクリック
57
+ - 初回は環境構築に数分かかります
58
+
59
+ 4. **開発開始:**
60
+ - すべての依存関係が自動でインストールされます
61
+ - VOICEVOX Core も自動でセットアップされます
62
+
63
+ ### 従来の方法(Makefile/venv)
64
+
65
+ <details>
66
+ <summary>Makefile を使った従来のセットアップ方法</summary>
67
+
68
+ ```bash
69
+ # 環境構築
70
+ make setup
71
+
72
+ # 実行内容:
73
+ # - 仮想環境の作成
74
+ # - 依存パッケージのインストール
75
+ # - VOICEVOX Coreのダウンロード
76
+ # - pre-commitの設定
77
+ ```
78
+
79
+ </details>
80
 
81
  ## 使い方
82
 
83
+ 1. **アプリケーションを起動:**
84
+ ```bash
85
  python app.py
86
  ```
87
 
88
+ 2. **ブラウザでアクセス:** `http://localhost:7860`
89
 
90
  3. ドキュメント(PDF、テキストファイルなど)をアップロードしてテキストを抽出
91
 
 
105
 
106
  11. 生成された音声を再生またはダウンロード
107
 
108
+ ## 開発者向け情報
109
+
110
+ ### Dev Container での開発
111
+
112
+ Dev Container 環境では以下のコマンドとタスクが利用できます:
113
+
114
+ | タスク | コマンド | VS Code タスク |
115
+ |--------|----------|---------------|
116
+ | アプリ実行 | `python app.py` | "Run Yomitalk App" |
117
+ | 全テスト | `pytest tests/` | "Run All Tests" |
118
+ | 単体テスト | `pytest tests/unit/` | "Run Unit Tests" |
119
+ | E2Eテスト | `E2E_TEST_MODE=true pytest tests/e2e/` | "Run E2E Tests" |
120
+ | コード整形 | `black . && isort .` | "Format Code" |
121
+ | 静的解析 | `flake8 . && mypy .` | "Run Linting" |
122
+ | Pre-commit | `pre-commit run --all-files` | "Run Pre-commit" |
123
+
124
+ ### ファイル構成
125
+
126
+ 詳細な設計情報は [`docs/design.md`](docs/design.md) を参照してください。
127
+
128
+ ### 開発ルール
129
+
130
+ - **コミット前チェック必須**: すべてのコミットは pre-commit フックを通過する必要があります
131
+ - **`--no-verify` 禁止**: pre-commit フックのバイパスは禁止されています
132
+ - **型チェック**: mypy による型チェックを通過する必要があります
133
+ - **テスト**: 新機能には適切なテストを追加してください
134
+
135
  ## APIキーの取得方法
136
 
137
  ### OpenAI APIキー
docker-compose.dev.yml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Development docker-compose for those preferring direct docker-compose usage
2
+ # Usage: docker-compose -f docker-compose.dev.yml up
3
+ version: '3.8'
4
+
5
+ services:
6
+ yomitalk-dev:
7
+ build:
8
+ context: .
9
+ dockerfile: .devcontainer/Dockerfile
10
+ volumes:
11
+ - .:/workspace:cached
12
+ - yomitalk-data:/workspace/data
13
+ - yomitalk-voicevox:/workspace/voicevox_core
14
+ # Mount for git credentials
15
+ - ~/.gitconfig:/home/vscode/.gitconfig:ro
16
+ environment:
17
+ - VOICEVOX_ACCEPT_AGREEMENT=true
18
+ - PAGER=cat
19
+ - LESSCHARSET=utf-8
20
+ - E2E_TEST_MODE=false
21
+ - PYTHONPATH=/workspace
22
+ ports:
23
+ - "7860:7860"
24
+ # Keep container running for development
25
+ command: sleep infinity
26
+ # Add capabilities for audio processing if needed
27
+ cap_add:
28
+ - SYS_PTRACE
29
+ security_opt:
30
+ - seccomp:unconfined
31
+ working_dir: /workspace
32
+ user: vscode
33
+
34
+ volumes:
35
+ yomitalk-data:
36
+ yomitalk-voicevox: