inspect_ai: Specifying a custom Dockerfile not named "Dockerfile" is broken
This commit attempts to fix an issue where is_dockerfile does not recognize Dockerfiles not named "Dockerfile". However, specifying such a named Dockerfile via sandbox=("docker", {name}.Dockerfile) still fails because Inspect still looks for a file named Dockerfile instead of the specified file. I believe this is because the .compose.yaml file which is generated does nothing to specify a non-default Dockerfile in the build attributes.
This makes it so that specifying sample-specific Dockerfiles (which are not named "Dockerfile") fails in a confusing way where Inspect will actually (attempt to) build an image from the default Dockerfile rather than the specified file.
A potential word-around for any users experiencing this error is to just specify a compose configuration that explicitly lists the named Dockerfile in its build.dockerfile attribute.
As an additional note, this commit fails to identify files named Dockerfile.{name} as Dockerfiles, which I understand is also an accepted convention. Should support for this be added to is_dockerfile?
Perhaps the if-else structure in the create() function of ComposeProject should also check for whether something is properly a Docker compose file so that an error is more explicitly surfaced if someone supplies a path to an invalid file type for the configuration.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 17 (11 by maintainers)
This is the minimal change that makes the feature work as intended (specify any Dockerfile as the sandbox config): https://github.com/UKGovernmentBEIS/inspect_ai/pull/1332
I am open to discussing further change/enhancements/etc. based on people’s patterns of use, but I think it’s best to make a straightforward fix to put the defect behind us.
I think will be pretty easy to determine if its a Dockerfile or compose file by using name heuristics (the existing
is_dockerfile, presence of.ymlor.yamlin the file extension, etc.)Okay, I just merged the
Dockerfile.namechange (as this convention is referenced in the Docker CLI docs). Could you suggest the appropriate change to.compose.yamlgeneration? (not asking for a PR, just a description of the logic to ensure that I have followed the discussion correctly)