docker-runtime-resources-test.sh 1015 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. set -eu
  3. repo_root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
  4. cd "$repo_root"
  5. fail() {
  6. printf 'docker runtime resources test failed: %s\n' "$1" >&2
  7. exit 1
  8. }
  9. assert_line() {
  10. file=$1
  11. line=$2
  12. grep -Fqx "$line" "$file" || fail "$file is missing: $line"
  13. }
  14. assert_count() {
  15. file=$1
  16. line=$2
  17. expected=$3
  18. actual=$(grep -Fxc "$line" "$file" || true)
  19. [ "$actual" -eq "$expected" ] || fail "$file has $actual occurrences of '$line', expected $expected"
  20. }
  21. test -s backend/resources/model-pricing/model_prices_and_context_window.json || \
  22. fail 'fallback pricing data is missing or empty'
  23. assert_line Dockerfile.goreleaser 'COPY --chown=sub2api:sub2api backend/resources /app/resources'
  24. assert_line deploy/Dockerfile 'COPY --from=backend-builder --chown=sub2api:sub2api /app/backend/resources /app/resources'
  25. assert_count .goreleaser.yaml ' - backend/resources' 4
  26. assert_count .goreleaser.simple.yaml ' - backend/resources' 1
  27. printf 'docker runtime resources test passed\n'