1- FROM python:3.12
1+ # FROM python:3.12
22
3- # Ensure Python output is not buffered
4- ENV PYTHONUNBUFFERED=1
3+ # # Ensure Python output is not buffered
4+ # ENV PYTHONUNBUFFERED=1
55
6- # Set working directory inside the container
6+ # # Set working directory inside the container
7+ # WORKDIR /app
8+
9+ # # Copy dependencies list to container
10+ # COPY requirements.txt .
11+
12+ # # Install dependencies
13+ # RUN pip install --no-cache-dir -r requirements.txt
14+
15+ # # Copy the entire application to the container
16+ # COPY . .
17+
18+ # # Create static directory
19+ # RUN mkdir -p /app/static
20+
21+ # # # Collect static files during image build
22+ # # RUN python manage.py collectstatic --noinput
23+
24+
25+ # # Expose the port your application will run on
26+ # EXPOSE 8000
27+
28+ # # Default command to run the application
29+ # CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
30+
31+ # Use a slim Python image to reduce size
32+ FROM python:3.12-slim
33+
34+ # Set environment variables
35+ ENV PYTHONUNBUFFERED=1 \
36+ PYTHONDONTWRITEBYTECODE=1 \
37+ PIP_NO_CACHE_DIR=1 \
38+ PIP_DISABLE_PIP_VERSION_CHECK=1
39+
40+ # Install system dependencies (needed for PostgreSQL, etc.)
41+ RUN apt-get update && \
42+ apt-get install -y --no-install-recommends \
43+ build-essential \
44+ libpq-dev \
45+ && rm -rf /var/lib/apt/lists/*
46+
47+ # Set the working directory
748WORKDIR /app
849
9- # Copy dependencies list to container
50+ # Copy and install Python dependencies first (for caching)
1051COPY requirements.txt .
11-
12- # Install dependencies
1352RUN pip install --no-cache-dir -r requirements.txt
1453
15- # Copy the entire application to the container
54+ # Copy the rest of the application
1655COPY . .
1756
18- # Create static directory
19- RUN mkdir -p /app/static
20-
21- # # Collect static files during image build
22- # RUN python manage.py collectstatic --noinput
57+ # Collect static files (Render expects them in `/app/static`)
58+ RUN python manage.py collectstatic --noinput
2359
60+ # Run as a non-root user (security best practice)
61+ RUN useradd -m appuser && chown -R appuser:appuser /app
62+ USER appuser
2463
25- # Expose the port your application will run on
64+ # Expose the port Render will use (8000 by default)
2665EXPOSE 8000
2766
28- # Default command to run the application
29- CMD ["python " , "manage.py " , "runserver" , " 0.0.0.0:8000" ]
67+ # Start Gunicorn (production-ready WSGI server)
68+ CMD ["gunicorn " , "--bind " , "0.0.0.0:8000" , "--workers" , "4" , "IOLGenv2_BackEnd.wsgi:application " ]
0 commit comments