fix(ci): isolate contract and image scans from host paths
MobilityOps acceptance / backend (pull_request) Failing after 2m20s
MobilityOps acceptance / frontend (pull_request) Successful in 1m24s
MobilityOps acceptance / e2e (pull_request) Skipped
Managed validation / full (pull_request) Canceled after 0s

This commit is contained in:
NuklearRabbit
2026-08-29 00:27:17 +02:00
parent a99aed9a5f
commit 2918608240
3 changed files with 34 additions and 17 deletions
+3 -17
View File
@@ -39,34 +39,20 @@ jobs:
- name: Contract drift gate - name: Contract drift gate
run: | run: |
docker compose -p mobilityops-ci -f compose.yaml -f compose.test.yaml run --rm \ docker compose -p mobilityops-ci -f compose.yaml -f compose.test.yaml run --rm \
-v "$PWD:/repo:ro" api python /repo/scripts/check-contracts.py api python scripts/check-contracts.py
python scripts/check-source-budgets.py python scripts/check-source-budgets.py
- name: Build production API image for vulnerability scan - name: Build production API image for vulnerability scan
run: | run: |
docker build --target runtime --build-arg VCS_REF="$GITHUB_SHA" \ docker build --target runtime --build-arg VCS_REF="$GITHUB_SHA" \
--tag mobilityops-api-ci --file backend/Dockerfile . --tag mobilityops-api-ci --file backend/Dockerfile .
- name: Production API image vulnerability scan (HIGH/CRITICAL) - name: Production API image vulnerability scan (HIGH/CRITICAL)
uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0 run: bash scripts/scan-ci-image.sh mobilityops-api-ci
with:
scan-type: image
image-ref: mobilityops-api-ci
format: table
severity: HIGH,CRITICAL
exit-code: "1"
ignore-unfixed: true
- name: Build production web image for vulnerability scan - name: Build production web image for vulnerability scan
run: | run: |
docker build --build-arg VCS_REF="$GITHUB_SHA" \ docker build --build-arg VCS_REF="$GITHUB_SHA" \
--tag mobilityops-web-ci frontend --tag mobilityops-web-ci frontend
- name: Production web image vulnerability scan (HIGH/CRITICAL) - name: Production web image vulnerability scan (HIGH/CRITICAL)
uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0 run: bash scripts/scan-ci-image.sh mobilityops-web-ci
with:
scan-type: image
image-ref: mobilityops-web-ci
format: table
severity: HIGH,CRITICAL
exit-code: "1"
ignore-unfixed: true
- name: Remove CI stack - name: Remove CI stack
if: always() if: always()
run: docker compose -p mobilityops-ci -f compose.yaml -f compose.test.yaml down -v --remove-orphans run: docker compose -p mobilityops-ci -f compose.yaml -f compose.test.yaml down -v --remove-orphans
+2
View File
@@ -24,6 +24,8 @@ FROM runtime-base AS test
COPY backend/requirements.lock ./requirements.lock COPY backend/requirements.lock ./requirements.lock
RUN pip install --no-cache-dir -r requirements.lock RUN pip install --no-cache-dir -r requirements.lock
COPY backend/tests ./tests COPY backend/tests ./tests
COPY contracts ./contracts
COPY scripts/check-contracts.py ./scripts/check-contracts.py
USER app USER app
FROM runtime-base AS runtime FROM runtime-base AS runtime
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TARGET_IMAGE="${1:?usage: scan-ci-image.sh <image>}"
TRIVY_IMAGE="aquasec/trivy@sha256:be1190afcb28352bfddc4ddeb71470835d16462af68d310f9f4bca710961a41e"
SAFE_NAME="$(printf '%s' "$TARGET_IMAGE" | tr -cs 'A-Za-z0-9._-' '-')"
ARCHIVE_RELATIVE="artifacts/.${SAFE_NAME}.tar"
ARCHIVE="$ROOT/$ARCHIVE_RELATIVE"
trap 'rm -f "$ARCHIVE"' EXIT
mkdir -p "$ROOT/artifacts"
docker image inspect "$TARGET_IMAGE" >/dev/null
docker save --output "$ARCHIVE" "$TARGET_IMAGE"
WORKSPACE_ARGS=(-v "$ROOT:/workspace:ro")
CONTAINER_ARCHIVE="/workspace/$ARCHIVE_RELATIVE"
if docker inspect "${HOSTNAME:-}" >/dev/null 2>&1; then
WORKSPACE_ARGS=(--volumes-from "$HOSTNAME")
CONTAINER_ARCHIVE="$ROOT/$ARCHIVE_RELATIVE"
fi
docker run --rm "${WORKSPACE_ARGS[@]}" "$TRIVY_IMAGE" image \
--input "$CONTAINER_ARCHIVE" \
--scanners vuln \
--severity HIGH,CRITICAL \
--ignore-unfixed \
--exit-code 1 \
--format table