Files
mtusi2026lab7/scripts/sync-docker-workspace.sh
T
dizi 97a52eeee6
CI / verify (pull_request) Failing after 3m27s
chore: finalize lab7 security verification
2026-11-06 21:39:31 +03:00

39 lines
873 B
Bash
Executable File

#!/bin/sh
set -eu
[ "${DOCKER_WORKSPACE_MIRROR:-0}" = "1" ] || exit 0
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(CDPATH= cd -- "$script_dir/.." && pwd)
mode=${1:-sync}
case "$mode" in
sync|--pull-scan) ;;
*) echo "usage: $0 [--pull-scan]" >&2; exit 2 ;;
esac
[ -f "$repo_dir/compose.yaml" ] || {
echo "repository checkout is incomplete" >&2
exit 1
}
container=$(docker create --network none \
-v "$repo_dir:/workspace" \
alpine:3.24.2 /bin/true)
cleanup() {
docker rm -f "$container" >/dev/null 2>&1 || true
}
trap cleanup EXIT HUP INT TERM
if [ "$mode" = "--pull-scan" ]; then
destination=$repo_dir/evidence/runtime/security-scan
mkdir -p "$destination"
docker cp "$container:/workspace/evidence/runtime/security-scan/." "$destination"
exit 0
fi
docker cp "$repo_dir/." "$container:/workspace"