Copying application source and running tests

The final steps in the test stage are to copy the application source into the container and add support for running tests:

# Test stageFROM alpine AS testLABEL application=todobackend# Install basic utilitiesRUN apk add --no-cache bash git# Install build dependenciesRUN apk add --no-cache gcc python3-dev libffi-dev musl-dev linux-headers mariadb-devRUN pip3 install wheel# Copy requirementsCOPY /src/requirements* /build/WORKDIR /build# Build and install requirementsRUN pip3 wheel -r requirements_test.txt --no-cache-dir --no-inputRUN pip3 install -r requirements_test.txt -f /build --no-index --no-cache-dir# Copy source codeCOPY /src /appWORKDIR /app# Test entrypointCMD ["python3", "manage.py", "test", ...

Get Docker on Amazon Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.