NitinBot001 commited on
Commit
8839e04
·
verified ·
1 Parent(s): 67f7621

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -0
Dockerfile ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.11-slim
3
+
4
+ # Set environment variables
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 required for some Python packages
12
+ RUN apt-get update && apt-get install -y --no-install-recommends \
13
+ gcc \
14
+ python3-dev \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ # Copy requirements first to leverage Docker cache
18
+ COPY requirements.txt .
19
+
20
+ # Install Python dependencies
21
+ RUN pip install --no-cache-dir -r requirements.txt
22
+
23
+ # Create a non-root user and switch to it
24
+ RUN groupadd -r appuser && useradd -r -g appuser appuser
25
+ RUN chown -R appuser:appuser /app
26
+ USER appuser
27
+
28
+ # Copy the rest of the application
29
+ COPY --chown=appuser:appuser . .
30
+
31
+ # Expose the port the app runs on
32
+ EXPOSE 7860
33
+
34
+ # Command to run the application
35
+ CMD ["python", "server.py"]