-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.test
More file actions
83 lines (67 loc) · 1.99 KB
/
Dockerfile.test
File metadata and controls
83 lines (67 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Use a specific version of Ubuntu LTS as base
FROM ubuntu:22.04
# Set default Python version
ARG PYTHON_VERSION=3.10
# Set non-interactive frontend for apt-get
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/app/python
# Install system dependencies
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
git \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
make \
python3 \
python3-pip \
python3-venv \
python-is-python3 \
&& rm -rf /var/lib/apt/lists/* \
&& ln -sf /usr/bin/python3 /usr/bin/python \
&& python --version \
&& pip --version
# Create non-root user and set up directories
RUN useradd -m appuser && \
mkdir -p /app && \
chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Set working directory
WORKDIR /app
# Create necessary directories
RUN mkdir -p /app/python
# Copy the application code and test requirements
COPY --chown=appuser:appuser python/ /app/python/
COPY --chown=appuser:appuser test-requirements.txt /app/
# Install test requirements
RUN pip install --no-cache-dir -r /app/test-requirements.txt
# Set working directory
WORKDIR /app/python
# Install the package in development mode with test and dev dependencies
RUN pip install --no-cache-dir -e ".[test,dev]"
# Install additional test dependencies not covered by extras
RUN pip install --no-cache-dir \
pytest-cov \
pytest-mqtt \
pytest-httpbin \
pytest-asyncio \
pytest-mock \
testinfra \
molecule \
molecule-plugins[docker]
# Copy the rest of the application
WORKDIR /app
COPY --chown=appuser:appuser . /app/
# Set the working directory to the python directory where the package is located
WORKDIR /app/python
# Set the entrypoint to run tests
ENTRYPOINT ["/app/tests/run_tests.sh"]
# Default command (can be overridden)
CMD ["-t", "all"]