|
| 1 | +# wdoc Docker Setup |
| 2 | + |
| 3 | +This directory contains a dockerized Gradio web interface for wdoc, designed for easy deployment and use. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +1. **Configure environment variables**: Copy and edit the environment file: |
| 8 | + ```bash |
| 9 | + cp custom_env.example custom_env |
| 10 | + # Edit custom_env to add your API keys (OPENAI_API_KEY, etc.) |
| 11 | + ``` |
| 12 | + |
| 13 | +2. **Start the service**: |
| 14 | + ```bash |
| 15 | + docker-compose up -d |
| 16 | + ``` |
| 17 | + |
| 18 | +3. **Access the web interface**: Open your browser to `http://localhost:7618` |
| 19 | + |
| 20 | +## Architecture |
| 21 | + |
| 22 | +- **Container user**: Runs as non-root user `wdoc` (UID:GID 1000:1000) for security |
| 23 | +- **Port**: Exposes Gradio on port 7618 (mapped from internal port 7860) |
| 24 | +- **Volumes**: |
| 25 | + - `./vectorstore`: Persistent storage for document embeddings |
| 26 | + - `./wdoc_cache`: LLM cache to reduce API costs and improve performance |
| 27 | + |
| 28 | +## Troubleshooting |
| 29 | + |
| 30 | +### Permission Errors |
| 31 | + |
| 32 | +If you encounter permission errors on first startup, particularly related to the cache directory, this is typically because Docker created the volume directories with root ownership. |
| 33 | + |
| 34 | +**Solution**: Change ownership of the docker directory to match the container's user (UID:GID 1000:1000): |
| 35 | + |
| 36 | +```bash |
| 37 | +# From the docker directory |
| 38 | +sudo chown -R 1000:1000 ./vectorstore ./wdoc_cache |
| 39 | + |
| 40 | +# Or if the directories don't exist yet: |
| 41 | +mkdir -p ./vectorstore ./wdoc_cache |
| 42 | +sudo chown -R 1000:1000 ./vectorstore ./wdoc_cache |
| 43 | +``` |
| 44 | + |
| 45 | +**Alternative**: If you're running with a different user ID, you can modify the `docker-compose.yml` to use your current user: |
| 46 | + |
| 47 | +```yaml |
| 48 | +user: "${UID}:${GID}" |
| 49 | +``` |
| 50 | +
|
| 51 | +Then run with: |
| 52 | +```bash |
| 53 | +UID=$(id -u) GID=$(id -g) docker-compose up -d |
| 54 | +``` |
| 55 | + |
| 56 | +### Checking Logs |
| 57 | + |
| 58 | +To view the application logs: |
| 59 | +```bash |
| 60 | +docker-compose logs -f wdoc-gui |
| 61 | +``` |
| 62 | + |
| 63 | +### Rebuilding After Changes |
| 64 | + |
| 65 | +If you've modified `gui.py` or `Dockerfile`: |
| 66 | +```bash |
| 67 | +docker-compose down |
| 68 | +docker-compose build --no-cache |
| 69 | +docker-compose up -d |
| 70 | +``` |
| 71 | + |
| 72 | +## Configuration |
| 73 | + |
| 74 | +### Environment Variables |
| 75 | + |
| 76 | +Create a `custom_env` file with your configuration: |
| 77 | + |
| 78 | +```bash |
| 79 | +# Required: API keys for your LLM provider |
| 80 | +OPENAI_API_KEY=sk-... |
| 81 | +# Or for other providers: |
| 82 | +# ANTHROPIC_API_KEY=... |
| 83 | +# GEMINI_API_KEY=... |
| 84 | + |
| 85 | +# Optional: Default models |
| 86 | +WDOC_DEFAULT_MODEL=openai/gpt-4o-mini |
| 87 | +WDOC_DEFAULT_EMBED_MODEL=openai/text-embedding-3-small |
| 88 | + |
| 89 | +# Optional: Langfuse integration (if using) |
| 90 | +LANGFUSE_PUBLIC_KEY=pk-... |
| 91 | +LANGFUSE_SECRET_KEY=sk-... |
| 92 | +LANGFUSE_HOST=https://cloud.langfuse.com |
| 93 | +``` |
| 94 | + |
| 95 | +### Volume Paths |
| 96 | + |
| 97 | +You can customize volume paths using environment variables in `docker-compose.yml`: |
| 98 | + |
| 99 | +```bash |
| 100 | +VECTORSTORE_PATH=/your/custom/path/vectorstore docker-compose up -d |
| 101 | +CACHE_PATH=/your/custom/path/cache docker-compose up -d |
| 102 | +``` |
| 103 | + |
| 104 | +## Security Notes |
| 105 | + |
| 106 | +- The container runs as a non-root user for improved security |
| 107 | +- Security option `no-new-privileges` prevents privilege escalation |
| 108 | +- No unnecessary capabilities are granted |
| 109 | +- Network access is controlled (uses `host.docker.internal` for local services like Langfuse) |
| 110 | + |
| 111 | +## For Developers |
| 112 | + |
| 113 | +### Building Locally |
| 114 | + |
| 115 | +```bash |
| 116 | +docker build -t wdoc-gui . |
| 117 | +docker run -p 7618:7860 \ |
| 118 | + -v $(pwd)/vectorstore:/app/vectorstore \ |
| 119 | + -v $(pwd)/wdoc_cache:/home/wdoc/.cache/wdoc \ |
| 120 | + --env-file custom_env \ |
| 121 | + wdoc-gui |
| 122 | +``` |
| 123 | + |
| 124 | +### Modifying the GUI |
| 125 | + |
| 126 | +The Gradio interface is defined in `gui.py`. After making changes, rebuild the container to see them take effect. |
| 127 | + |
| 128 | +## Additional Resources |
| 129 | + |
| 130 | +- [wdoc GitHub Repository](https://github.com/thiswillbeyourgithub/wdoc) |
| 131 | +- [wdoc Documentation](https://wdoc.readthedocs.io/) |
| 132 | +- [Gradio Documentation](https://gradio.app) |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +*This Docker setup was created with assistance from [aider.chat](https://github.com/Aider-AI/aider/)* |
0 commit comments