@@ -8,35 +8,44 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
8
8
PIP_DISABLE_PIP_VERSION_CHECK=1 \
9
9
PIP_DEFAULT_TIMEOUT=100
10
10
11
- # Set the working directory to the root of the project (relative to pyproject.toml)
11
+ # Set the working directory
12
12
WORKDIR /usr/src/app
13
13
14
14
# Copy the entire project into the container
15
15
COPY . .
16
16
17
- # Install Poetry
18
- RUN pip install poetry
17
+ # Install system dependencies and clean up
18
+ RUN apt-get update && \
19
+ apt-get install -y --no-install-recommends \
20
+ git \
21
+ && rm -rf /var/lib/apt/lists/*
19
22
20
- # Configure Poetry to avoid virtual environments and install dependencies
21
- RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi
23
+ # Install Poetry and pytest
24
+ RUN pip install --no-cache-dir poetry pytest
22
25
23
- # Install pytest explicitly
24
- RUN pip install pytest
26
+ # Configure Poetry and install project dependencies
27
+ RUN poetry config virtualenvs.create false && \
28
+ poetry install --no-interaction --no-ansi
25
29
26
- # Check if pytest is installed successfully
27
- RUN pytest --version || echo "pytest not found"
28
-
29
- # Ensure the logs directory has correct permissions
30
+ # Create logs directory with proper permissions
30
31
RUN mkdir -p /usr/src/app/logs && chmod -R 777 /usr/src/app/logs
31
32
32
- # Ensure that the PATH includes the directory where pytest is installed
33
- ENV PATH="/usr/local/bin:$PATH"
33
+ # Add pytest to PATH and verify installation
34
+ ENV PATH="/usr/local/bin:/root/.local/bin:$PATH"
35
+
36
+ # Verify pytest installation
37
+ RUN python -m pytest --version
38
+
39
+ # Create a shell script to run tests
40
+ COPY <<EOF /usr/local/bin/run-tests.sh
41
+ # !/bin/bash
42
+ python -m pytest "\$ @"
43
+ EOF
34
44
35
- # List files in /usr/src/app to check if pytest is installed correctly
36
- RUN ls -l /usr/src/app
45
+ RUN chmod +x /usr/local/bin/run-tests.sh
37
46
38
- # Set the working directory to the tests directory inside the container
39
- WORKDIR /usr/src/app/ tests
47
+ # Set the ENTRYPOINT to use the shell script
48
+ ENTRYPOINT [ " /usr/local/bin/run- tests.sh" ]
40
49
41
- # Default command to run tests located in the /tests directory
42
- CMD pytest /usr/src/app/tests --continue-on-collection-errors --tb=short --disable-warnings | tee /usr/src/app/logs/test_logs.txt
50
+ # Set default pytest arguments
51
+ CMD [ " --continue-on-collection-errors" , " --tb=short" , " --disable-warnings" ]
0 commit comments