After I wrote the question I actually found the problem. When you define a context in docker-compose, the dockerfile:
bit is relative to that context. So the proper configuration would be:
test:
build:
context: ../
dockerfile: docker/cli/Dockerfile
I hope this helps someone…