From c31242a50059fc952006f28b0de5d322b93400ef Mon Sep 17 00:00:00 2001 From: hz Date: Mon, 20 Jul 2026 20:38:48 -0500 Subject: [PATCH] Run deployment tests from Docker build context --- .gitea/scripts/deploy-environment.sh | 10 +++------- api/QuestionsApi.Tests/Dockerfile | 8 ++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 api/QuestionsApi.Tests/Dockerfile diff --git a/.gitea/scripts/deploy-environment.sh b/.gitea/scripts/deploy-environment.sh index 89706c6..d0823b4 100644 --- a/.gitea/scripts/deploy-environment.sh +++ b/.gitea/scripts/deploy-environment.sh @@ -14,12 +14,13 @@ NODES="${NODES:-192.168.86.72 192.168.86.73 192.168.86.74}" BUILD_TAG="$(git rev-parse HEAD)" API_IMAGE="step3-questions:${BUILD_TAG}" WEB_IMAGE="step3-web:${BUILD_TAG}" +TEST_IMAGE="step3-tests:${BUILD_TAG}" API_TAR="/tmp/step3-questions-${DEPLOYMENT_ENVIRONMENT}.tar" WEB_TAR="/tmp/step3-web-${DEPLOYMENT_ENVIRONMENT}.tar" cleanup() { rm -f "${API_TAR}" "${WEB_TAR}" - docker image rm "${API_IMAGE}" "${WEB_IMAGE}" 2>/dev/null || true + docker image rm "${API_IMAGE}" "${WEB_IMAGE}" "${TEST_IMAGE}" 2>/dev/null || true docker image prune -f >/dev/null || true } trap cleanup EXIT @@ -32,12 +33,7 @@ docker builder prune -af || true docker system df df -h -docker run --rm \ - --volume "${PWD}:/src" \ - --workdir /src \ - --env DOTNET_CLI_TELEMETRY_OPTOUT=1 \ - mcr.microsoft.com/dotnet/sdk:8.0 \ - dotnet test api/QuestionsApi.Tests/QuestionsApi.Tests.csproj -c Release +docker build -f api/QuestionsApi.Tests/Dockerfile -t "${TEST_IMAGE}" . docker build --build-arg BUILD_REVISION="${BUILD_TAG}" -t "${API_IMAGE}" api/QuestionsApi docker build \ --build-arg BUILD_REVISION="${BUILD_TAG}" \ diff --git a/api/QuestionsApi.Tests/Dockerfile b/api/QuestionsApi.Tests/Dockerfile new file mode 100644 index 0000000..8445f7f --- /dev/null +++ b/api/QuestionsApi.Tests/Dockerfile @@ -0,0 +1,8 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 + +WORKDIR /src +COPY api/ ./api/ + +ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 + +RUN dotnet test api/QuestionsApi.Tests/QuestionsApi.Tests.csproj -c Release