# Use an official Python runtime as a parent image FROM python:3.9-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Set the working directory in the container WORKDIR /app # Copy the requirements file into the container COPY requirements.txt . # Install dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the current directory contents into the container COPY . . # Copy wait-for-it script and make it executable COPY wait-for-it.sh /wait-for-it.sh RUN chmod +x /wait-for-it.sh # Expose port 8000 for the Django app EXPOSE 8000 # Run the Django development server, wait for the DB to be ready first CMD ["/wait-for-it.sh", "db:5432", "--", "python", "manage.py", "runserver", "0.0.0.0:8000"]