From 110a3a3164282aded2dcbdf60847f1efcd45f055 Mon Sep 17 00:00:00 2001 From: Garima Ketan Chauhan Date: Wed, 2 Apr 2025 23:33:45 +0200 Subject: [PATCH] Update Dockerfile.test --- backend/tests/Dockerfile.test | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/backend/tests/Dockerfile.test b/backend/tests/Dockerfile.test index 01d802e..ab496d2 100644 --- a/backend/tests/Dockerfile.test +++ b/backend/tests/Dockerfile.test @@ -1,21 +1,26 @@ -# Use an official Python runtime as a base image -FROM python:3.11-slim - -# Set environment variables -ENV PYTHONUNBUFFERED=1 +# Use an official Python runtime as a parent image +FROM python:3.9-buster # Set the working directory WORKDIR /app -# Install system dependencies (if needed) -RUN apt-get update && apt-get install -y gcc libpq-dev && rm -rf /var/lib/apt/lists/* +# Add Google's public DNS for name resolution +RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf + +# Install system dependencies (including gcc and libpq-dev) +RUN apt-get update && \ + apt-get install -y apt-transport-https gcc libpq-dev && \ + rm -rf /var/lib/apt/lists/* # Copy the requirements file into the container and install dependencies COPY requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -r /app/requirements.txt coverage -# Copy the Django project (assuming you want the whole backend code) -COPY ../../ /app/ +# Copy the rest of the application files +COPY . /app/ + +# Set environment variables +ENV PYTHONUNBUFFERED 1 -# Run Django tests with coverage -CMD ["sh", "-c", "coverage run --source=. manage.py test && coverage report -m && coverage html"] +# Run tests with coverage +CMD ["python", "manage.py", "test", "--coverage"]