File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ __pycache__
2+ * .pyc
3+ * .pyo
4+ * .swp
5+ .env
Original file line number Diff line number Diff line change 1+ # Use the official Python 3.9 slim image as the base
2+ FROM python:3.9-slim
3+
4+ # Set environment variables to prevent Python from writing .pyc files and to buffer outputs
5+ ENV PYTHONDONTWRITEBYTECODE=1
6+ ENV PYTHONUNBUFFERED=1
7+
8+ # Set the working directory in the container
9+ WORKDIR /app
10+
11+ # Install system dependencies
12+ RUN apt-get update && apt-get install -y --no-install-recommends \
13+ build-essential \
14+ && rm -rf /var/lib/apt/lists/*
15+
16+ # Copy the requirements file into the container
17+ COPY requirements.txt .
18+
19+ # Upgrade pip and install Python dependencies
20+ RUN pip install --upgrade pip && \
21+ pip install --no-cache-dir -r requirements.txt
22+
23+ # Copy the rest of the application code into the container
24+ COPY . .
25+
26+ # Expose the port that Gradio uses
27+ EXPOSE 7860
28+
29+ # Define environment variable for OpenAI API Key (to be provided at runtime)
30+ ENV OPENAI_API_KEY=""
31+
32+ # Specify the command to run the application
33+ CMD ["python" , "app.py" ]
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ To run the PDF2Audio app:
6161
62621 . Ensure you're in the project directory and your Conda environment is activated:
6363 ```
64- conda activate pdf2audio
64+ conda activate pdf2audio
6565 ```
6666
67672 . Run the Python script that launches the Gradio interface:
@@ -73,6 +73,24 @@ To run the PDF2Audio app:
7373
74744 . Use the Gradio interface to upload a PDF file and convert it to audio.
7575
76+ ## Using Docker
77+
78+ 1 . ** Build the Docker image:**
79+ ``` bash
80+ docker build -t pdf2audio .
81+ ```
82+
83+ 2 . ** Run the Docker container:**
84+ ``` bash
85+ docker run -p 7860:7860 -e OPENAI_API_KEY=your_api_key_here pdf2audio
86+ ```
87+
88+ - Replace ` your_api_key_here ` with your actual OpenAI API key.
89+ - The ` -p 7860:7860 ` mapping exposes port 7860 of the container to your host machine, allowing you to access the Gradio interface.
90+
91+ 3 . ** Access the Gradio interface:**
92+ Open your web browser and go to ` http://localhost:7860 ` .
93+
7694## How to Use
7795
78961 . Upload one or more PDF files
You can’t perform that action at this time.
0 commit comments