forked from mathialm/secfit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |