Skip to content

Commit

Permalink
Update Dockerfile.test
Browse files Browse the repository at this point in the history
  • Loading branch information
Garima Ketan Chauhan authored and GitHub Enterprise committed Apr 2, 2025
1 parent ac612d3 commit 2743017
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions backend/tests/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
FROM python:3.12-slim
# backend/tests/Dockerfile.test
FROM python:3.9-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set work directory (inside container)
WORKDIR /app

# Install dependencies from requirements.txt
COPY ../requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Install coverage (if not included in requirements.txt)
RUN pip install --no-cache-dir coverage
# Copy requirements from backend/ (parent of tests/)
COPY ../requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install coverage # Explicit install if not in requirements.txt

# Copy the entire backend folder into the container
COPY .. /app/backend
# Copy necessary files from project root
COPY ../manage.py .
COPY ../your_app/ ./your_app # Replace 'your_app' with your Django app name
COPY ../pytest.ini . # If you have one
COPY .coveragerc . # If you have custom coverage config

# Set the working directory to the backend folder
WORKDIR /app/backend
# Copy tests
COPY ../tests/ ./tests # If you have tests outside the app

# Run tests with coverage
CMD ["bash", "-c", "pytest --cov=backend --cov-report=xml"]
# Command to run tests with coverage
CMD ["sh", "-c", "coverage run --source='.' manage.py test && coverage report && coverage xml"]

0 comments on commit 2743017

Please sign in to comment.