From d84d3f8911af814d6fb30b8d719c7df19e94f60d Mon Sep 17 00:00:00 2001 From: jamshale Date: Mon, 9 Dec 2024 23:05:00 +0000 Subject: [PATCH] Only copy agent code in dockerfiles Signed-off-by: jamshale --- docker/Dockerfile | 9 +++++---- docker/Dockerfile.run | 4 ++-- docker/Dockerfile.test | 3 ++- docs/testing/UnitTests.md | 4 ++-- scripts/run_tests | 8 ++++---- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 89e2e3da54..621b5b0538 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,7 +3,8 @@ FROM python:${python_version}-slim-bullseye AS build WORKDIR /src -COPY . . +COPY ./acapy_agent ./acapy_agent +COPY ./pyproject.toml ./poetry.lock ./ RUN pip install --no-cache-dir poetry RUN poetry build @@ -12,7 +13,7 @@ FROM python:${python_version}-slim-bullseye AS main ARG uid=1001 ARG user=aries -ARG acapy_name="aries-cloudagent" +ARG acapy_name="acapy-agent" ARG acapy_version ARG acapy_reqs=[didcommv2] @@ -26,7 +27,7 @@ ENV HOME="/home/$user" \ RUST_LOG=warn \ SHELL=/bin/bash \ SUMMARY="$acapy_name image" \ - DESCRIPTION="$acapy_name provides a base image for running Hyperledger Aries agents in Docker. \ + DESCRIPTION="$acapy_name provides a base image for running acapy agents in Docker. \ This image layers the python implementation of $acapy_name $acapy_version. Based on Debian Buster." LABEL summary="$SUMMARY" \ @@ -100,7 +101,7 @@ RUN acapy_agent_package=$(find ./ -name "acapy_agent*.whl" | head -n 1) && \ rm acapy_agent*.whl && \ chmod +rx $(python -m site --user-site) $HOME/.local -# Clean-up unneccessary build dependencies and reduce final image size +# Clean-up unnecessary build dependencies and reduce final image size USER root RUN apt-get purge -y --auto-remove build-essential diff --git a/docker/Dockerfile.run b/docker/Dockerfile.run index 706588d0b5..e2740b369e 100644 --- a/docker/Dockerfile.run +++ b/docker/Dockerfile.run @@ -9,7 +9,7 @@ RUN apt-get update -y && \ WORKDIR /usr/src/app -# For consistency with base images, include curl for healthchecks +# For consistency with base images, include curl for health checks RUN apt-get update && apt-get install -y curl && apt-get clean RUN pip install --no-cache-dir poetry @@ -21,6 +21,6 @@ RUN mkdir -p log && chmod -R ug+rw log ARG all_extras=0 RUN if ! [ -z ${all_extras} ]; then poetry install --all-extras; else poetry install -E "didcommv2"; fi -COPY . . +COPY ./acapy_agent ./acapy_agent ENTRYPOINT ["/bin/bash", "-c", "poetry run aca-py \"$@\"", "--"] diff --git a/docker/Dockerfile.test b/docker/Dockerfile.test index fb4e9e98f1..98908b08fc 100644 --- a/docker/Dockerfile.test +++ b/docker/Dockerfile.test @@ -17,6 +17,7 @@ RUN mkdir acapy_agent && touch acapy_agent/__init__.py ARG all_extras=0 RUN if ! [ -z ${all_extras} ]; then poetry install --no-directory --all-extras --with=dev; else poetry install --no-directory -E "didcommv2" --with=dev; fi -COPY . . +COPY ./acapy_agent ./acapy_agent +COPY ./conftest.py ./ ENTRYPOINT ["/bin/bash", "-c", "poetry run pytest \"$@\"", "--"] diff --git a/docs/testing/UnitTests.md b/docs/testing/UnitTests.md index 776611405d..e453255d9c 100644 --- a/docs/testing/UnitTests.md +++ b/docs/testing/UnitTests.md @@ -7,7 +7,7 @@ This [video](https://youtu.be/yJ6LpAiVNFM) is a presentation of the material cov ## Running unit tests in ACA-Py - `./scripts/run_tests` -- `./scripts/run_tests aries_cloudagent/protocols/out_of_band/v1_0/tests` +- `./scripts/run_tests acapy_agent/protocols/out_of_band/v1_0/tests` Note: The `bbs` library is not installed with ACA-Py by default, therefore unit tests involving BBS Signatures are disabled. To run BBS tests add the `--all-extras` flag: @@ -64,7 +64,7 @@ def test_sub_unsub(event_bus: EventBus, processor): assert not event_bus.topic_patterns_to_subscribers ``` -From aries_cloudagent/core/event_bus.py +From acapy_agent/core/event_bus.py ```python class EventBus: diff --git a/scripts/run_tests b/scripts/run_tests index 5f6ede8dad..af9c9c91be 100755 --- a/scripts/run_tests +++ b/scripts/run_tests @@ -15,7 +15,7 @@ for arg in "$@"; do done if [[ $FAST -eq 0 ]]; then - $CONTAINER_RUNTIME build --platform linux/amd64 -t aries-cloudagent-test -f ../docker/Dockerfile.test --build-arg "all_extras=$ALL_EXTRAS" .. || exit 1 + $CONTAINER_RUNTIME build --platform linux/amd64 -t acapy-agent-test -f ../docker/Dockerfile.test --build-arg "all_extras=$ALL_EXTRAS" .. || exit 1 fi DOCKER_ARGS="" @@ -33,7 +33,7 @@ if [ -n "${ENABLE_PTVSD}" ]; then fi if [[ $FAST -eq 1 ]]; then - DOCKER_ARGS="${DOCKER_ARGS} -v $(pwd)/../aries_cloudagent:/usr/src/app/aries_cloudagent:z" + DOCKER_ARGS="${DOCKER_ARGS} -v $(pwd)/../acapy_agent:/usr/src/app/acapy_agent:z" fi if [ ! -d ../test-reports ]; then mkdir ../test-reports; fi @@ -47,7 +47,7 @@ if [ ! -z "$TEST_REDIS_CONFIG" ]; then DOCKER_ARGS="$DOCKER_ARGS -e TEST_REDIS_CONFIG=$TEST_REDIS_CONFIG" fi -$CONTAINER_RUNTIME run --rm -ti --name aries-cloudagent-runner \ +$CONTAINER_RUNTIME run --rm -ti --name acapy-agent-runner \ --platform linux/amd64 \ -v "$(pwd)/../test-reports:/usr/src/app/test-reports:z" \ - $DOCKER_ARGS aries-cloudagent-test "$@" + $DOCKER_ARGS acapy-agent-test "$@"