Samuraiog commited on
Commit
04d660e
·
verified ·
1 Parent(s): f444ea6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -16
Dockerfile CHANGED
@@ -1,25 +1,33 @@
1
- # Use a slim and modern Python base image
2
  FROM python:3.11-slim
3
 
4
- # Set the working directory inside the container
 
 
 
 
 
 
 
 
 
 
5
  WORKDIR /app
6
 
7
- # Copy the requirements file first to leverage Docker's layer caching
8
  COPY requirements.txt .
 
 
9
 
10
- # Install dependencies, including build tools for uvloop, then clean up
11
- # --no-cache-dir reduces image size
12
- RUN apt-get update && apt-get install -y build-essential && \
13
- pip install --no-cache-dir -r requirements.txt && \
14
- apt-get purge -y --auto-remove build-essential && \
15
- rm -rf /var/lib/apt/lists/*
16
 
17
- # Copy the rest of the application code
18
- COPY phoenix_fury_api.py .
19
-
20
- # Expose the port the API will run on
21
  EXPOSE 8000
22
 
23
- # Set the command to run the application using uvicorn
24
- # Using --workers 1 because we are managing parallelism with multiprocessing in Python
25
- CMD ["uvicorn", "phoenix_fury_api:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
 
 
 
 
1
+ # Use slim Python 3.11 image for minimal footprint
2
  FROM python:3.11-slim
3
 
4
+ # Prevent Python buffering & set UTF-8
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ PYTHONDONTWRITEBYTECODE=1 \
7
+ PYTHONIOENCODING=utf-8
8
+
9
+ # Install system deps (optional: for psutil)
10
+ RUN apt-get update && apt-get install -y --no-install-recommends \
11
+ procps \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # Create app dir
15
  WORKDIR /app
16
 
17
+ # Install Python deps
18
  COPY requirements.txt .
19
+ RUN pip install --no-cache-dir --upgrade pip && \
20
+ pip install --no-cache-dir -r requirements.txt
21
 
22
+ # Copy source
23
+ COPY phoenix_fury.py .
 
 
 
 
24
 
25
+ # Expose API port
 
 
 
26
  EXPOSE 8000
27
 
28
+ # Run as non-root (optional but recommended)
29
+ RUN useradd --create-home --shell /bin/bash appuser
30
+ USER appuser
31
+
32
+ # Launch with uvloop + optimized Uvicorn
33
+ CMD ["python", "phoenix_fury.py"]