mramjad commited on
Commit
b63e167
·
verified ·
1 Parent(s): c7761a1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -1
Dockerfile CHANGED
@@ -1,5 +1,28 @@
1
  FROM python:3.8-slim
 
 
 
 
 
 
 
2
  WORKDIR /app
3
- COPY . .
 
 
 
 
 
 
 
 
4
  RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
5
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.8-slim
2
+
3
+ # Set environment variables
4
+ ENV PYTHONDONTWRITEBYTECODE=1
5
+ ENV PYTHONUNBUFFERED=1
6
+
7
+ # Create a non-root user and switch to it
8
+ RUN useradd -m appuser
9
  WORKDIR /app
10
+ RUN chown appuser:appuser /app
11
+ USER appuser
12
+
13
+ # Create a virtual environment
14
+ RUN python -m venv /app/venv
15
+ ENV PATH="/app/venv/bin:$PATH"
16
+
17
+ # Install dependencies
18
+ COPY requirements.txt .
19
  RUN pip install --no-cache-dir -r requirements.txt
20
+
21
+ # Copy the application code
22
+ COPY --chown=appuser:appuser . .
23
+
24
+ # Expose the port
25
+ EXPOSE 7860
26
+
27
+ # Run the application
28
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]