Skip to content

Commit afb20b1

Browse files
committed
feat: Add Dockerfile and update README.md for Docker usage
1 parent 4a4bdc9 commit afb20b1

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
*.swp
5+
.env

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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"]

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ To run the PDF2Audio app:
6161

6262
1. Ensure you're in the project directory and your Conda environment is activated:
6363
```
64-
conda activate pdf2audio
64+
conda activate pdf2audio
6565
```
6666

6767
2. Run the Python script that launches the Gradio interface:
@@ -73,6 +73,24 @@ To run the PDF2Audio app:
7373

7474
4. 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

7896
1. Upload one or more PDF files

0 commit comments

Comments
 (0)