broadfield-dev commited on
Commit
f547e3d
·
verified ·
1 Parent(s): d94c33a

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -0
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
3
+
4
+ # Set environment variables to prevent interactive prompts during installation
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+
7
+ # Install system dependencies required by the application (only poppler)
8
+ RUN apt-get update && apt-get install -y \
9
+ poppler-utils \
10
+ && apt-get clean \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Create a non-root user for security
14
+ RUN useradd --create-home --shell /bin/bash appuser
15
+
16
+ # Set the working directory in the container
17
+ WORKDIR /app
18
+
19
+ # Copy the requirements file and install Python dependencies
20
+ # This is done in a separate layer to leverage Docker's build cache
21
+ COPY requirements.txt .
22
+ RUN pip install --no-cache-dir -r requirements.txt
23
+
24
+ # Copy the rest of the application's code into the container
25
+ COPY app.py .
26
+
27
+ # Change ownership of the app directory to the non-root user
28
+ RUN chown -R appuser:appuser /app
29
+
30
+ # Switch to the non-root user
31
+ USER appuser
32
+
33
+ # Expose the port the Gradio app will run on
34
+ EXPOSE 7860
35
+
36
+ # The command to run the Gradio application
37
+ # Gradio's launch() method will automatically bind to 0.0.0.0 inside Docker.
38
+ CMD ["python", "app.py"]