Cache test image to speed up CI backend test step
Add a 'test' stage to Dockerfile that extends runtime-base with the venv and test dependencies (pytest, fakeredis, etc.) pre-installed. Drone CI now builds and caches this image as :test, then uses it directly for running tests — eliminating apt-get and pip install on every build.
This commit is contained in:
parent
909cb8e04b
commit
96bcebdb40
2 changed files with 28 additions and 5 deletions
12
Dockerfile
12
Dockerfile
|
|
@ -28,7 +28,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||
libmariadb3 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Stage 3: Final image — combine venv from builder + runtime base
|
||||
# Stage 3: Test image — runtime deps + venv + test dependencies
|
||||
FROM runtime-base AS test
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/.venv /app/.venv
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
RUN pip install --no-cache-dir pytest pytest-asyncio pytest-xdist httpx aioresponses fakeredis
|
||||
|
||||
# Stage 4: Final image — combine venv from builder + runtime base
|
||||
FROM runtime-base
|
||||
|
||||
WORKDIR /app
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue