-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerfiles with different file names are not supported #127
Comments
Hi @ElijahAhianyo, thanks for the report! As an immediate workaround, you may be able to pass the [dD]ockerfile via the import dockerfile_parse
with open('./dockerfile', 'rb') as f:
dockerfile = dockerfile_parse.DockerfileParser(fileobj=f)
# do stuff with dockerfile
# can't use dockerfile anymore, fileobj is closed Or, if using a real file object is not convenient: import io
import dockerfile_parse
with open('./dockerfile', 'rb') as f:
in_memory_file = io.BytesIO(f.read())
dockerfile = dockerfile_parse.DockerfileParser(fileobj=in_memory_file)
# note that writes to the dockerfile (e.g. via the `envs` or `labels` attributes)
# will only be reflected in the in_memory_file, not on disk |
As for fixing the problem: maybe it would be good to support any arbitrary filename, rather than just For example, Not quite sure if there is a nice way to do that while preserving backwards compatibility. Maybe the @property
def dockerfile_path(self):
if os.path.isfile(self._path):
return self._path
else:
return os.path.join(self._path, DOCKERFILE_FILENAME) |
Hey, @chmeliik Thanks for getting back to me. Tried out your suggestion and seems to work. However, the only downside is having to use the |
Can we close this issue then? |
ah yes sure |
As seen in the official docker code base(https://github.com/docker/cli/blob/ab7cc485809455e6f1149aec5c00b6582066a396/cli/command/image/build/context.go#L324), there is a relative check for filenames with the format
dockerfile
aside the default nameDockerfile
.The library currently supports only the default name. That is because the
DOCKERFILE_FILENAME
constant(
dockerfile-parse/dockerfile_parse/constants.py
Line 16 in 48f8b95
I'm working on a usecase that requires parsing dockerfiles ending in
dockerfile
if they exist, however I seem to get this error:If this makes sense, I believe
DOCKER_FILENAME
should have a value of('Dockerfile', "dockerfile")
I am also willing to submit a PR if this issue is approved
The text was updated successfully, but these errors were encountered: