File size: 3,960 Bytes
c3cba0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Infinity Doctor Docker Instructions

This document provides detailed instructions on how to build and run the Infinity Doctor application using Docker.

## Prerequisites

- Install Docker Desktop for Windows from [https://www.docker.com/products/docker-desktop](https://www.docker.com/products/docker-desktop)
- Ensure Docker is running on your system
- API keys for Groq (and optionally ElevenLabs)

## Setting Up Environment Variables

1. Create a `.env` file in your project directory:

   ```
   # Copy the example file
   Copy-Item .env.example .env

   # Edit the file with your preferred editor
   notepad .env
   ```

2. Add your API keys to the `.env` file:
   ```
   GROQ_API_KEY=your_groq_api_key_here
   ELEVENLABS_API_KEY=your_elevenlabs_api_key_here
   ```

## Building and Running with Docker

### Option 1: Using the PowerShell script (Recommended for Windows)

1. Open PowerShell and navigate to the project directory
2. Run the provided script:

   ```
   .\run_docker.ps1
   ```

   This script will:

   - Check for a `.env` file and create one if it doesn't exist
   - Create necessary directories for data persistence
   - Build the Docker image
   - Run the container with all required parameters

### Option 2: Using Docker Compose

1. Run the application with Docker Compose:

   ```
   docker-compose up
   ```

   This will:

   - Build the Docker image if it doesn't exist
   - Run the container with mounted volumes for data persistence
   - Inject environment variables from your `.env` file
   - Map port 7860 to your host machine

2. To stop the application:

   ```
   docker-compose down
   ```

3. To rebuild the image and start fresh:
   ```
   docker-compose up --build
   ```

### Option 3: Using Docker commands directly

1. Build the Docker image:

   ```
   docker build -t infinity-doctor .
   ```

2. Run the Docker container with environment variables:
   ```
   docker run --rm -p 7860:7860 --env-file .env -v ${PWD}/images:/app/images -v ${PWD}/audio_data:/app/audio_data infinity-doctor
   ```

## Data Persistence

The Docker configuration is set up to persist data in two directories:

1. `./images`: For storing uploaded images
2. `./audio_data`: For storing audio recordings and generated audio responses

These directories are mounted as volumes in the Docker container, so your data will persist between container restarts.

## Accessing the Application

Once running, access the Infinity Doctor application at:
[http://localhost:7860](http://localhost:7860)

## Notes

- The Docker container exposes port 7860, which is the default port for Gradio applications
- Images uploaded through the interface will be saved in the `images` directory
- Audio files are processed within the container

## GPU Support (Optional)

If you have a compatible NVIDIA GPU and want to use it for faster processing:

1. Install [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html)

2. Add the `--gpus all` flag when running the container:

   ```
   docker run --rm --gpus all -p 7860:7860 --env-file .env -v ${PWD}/images:/app/images -v ${PWD}/audio_data:/app/audio_data infinity-doctor
   ```

3. Or modify the docker-compose.yml file to add:
   ```yaml
   deploy:
     resources:
       reservations:
         devices:
           - driver: nvidia
             count: 1
             capabilities: [gpu]
   ```

## Troubleshooting

- If you encounter issues with audio devices, note that Docker containers do not have direct access to the host's microphone. Use the text input option or upload pre-recorded audio files.

- If you get a "port already in use" error, change the port mapping in the docker run command:

  ```
  docker run --rm -p 7861:7860 --env-file .env infinity-doctor
  ```

  Then access the application at http://localhost:7861

- For permission errors with mounted volumes, ensure the user running Docker has write access to the directories.