-
Notifications
You must be signed in to change notification settings - Fork 628
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
Containerfile/Dockerfile parser #3970
Comments
I have not read this issue well yet.
This can be used as a start point. |
The main task of ctags is to extract names newly introduced in a target file. I don' think RUN introduces a new name. As far as reading https://www.tohoho-web.com/docker/dockerfile.html (Japanese), LABEL introduces names. So, the .ctags file should support it. The critical issue is the .ctags doesn't support a command with multiple lines like:
To extract DB_PORT, DB_USER, ..., we must switch the multi-table meta parser (https://docs.ctags.io/en/latest/optlib.html#advanced-pattern-matching-with-multiple-regex-tables) from the line-oriented meta parser. In my experience, A Containerfile is not very large. The performance of the parser may not be important, so a regex-based optlib parser is enough for the purpose. Do you want to implement such a parser by yourself? |
Thanks. I can't commit to owning a parser like this; but here's this for parsing from https://docs.docker.com/reference/dockerfile/ : $$('article table:first-of-type tr code').map((el) => el.innerText).reduce((a,b) => a + "\n" + b)
"ADD
ARG
CMD
COPY
ENTRYPOINT
ENV
EXPOSE
FROM
HEALTHCHECK
LABEL
MAINTAINER
ONBUILD
RUN
SHELL
STOPSIGNAL
USER
VOLUME
WORKDIR" |
I don't understand why you want to show all the commands. |
|
My use case for [universal-]ctags (#354) is vim-tagbar, which:
(FWIW where tagbar doesn't get it, vim-voom [2] has Markdown and RST outline editing. I still have a custom config, but e.g. SpaceVim [3] has TagBar installed too) [1] https://github.com/preservim/tagbar So IDK if just all of the tokens are worth indexing for Containerfile. |
Buildah (Apache 2.0) has many Containerfile test cases: |
jupyter-docker-stacks Dockerfiles aren't that long because they extend What's a better example of a gnarly Dockerfile where this functionality will be helpful? |
Regarding languages for Documentation, we violate the principle of "making a tag for definition." However, about Cotainerfile/Dockerfile, I want to uphold the principle.
This Dockerfile is quite a good example. Thank you. I am surprised at
Podman-build runs CPP. Therefore, Can we satisfy these requirements with .ctags? To get the answer to this question, I will implement the parser by myself. |
Isn't it possible to ~ distill such a grammar from a number of examples, such as the already-reference buildah and docker container builder test cases? Podman builds containers with Buildah. Nerdctl and Docker > 23.0 build containers with BuildKit. BuildKit; where are the Dockerfile syntax examples tested by BuildKit?:
Buildah's test Dockerfiles appear to be the most complete set of test Dockerfiles / Containerfiles I'm aware of. |
Close universal-ctags#3970 Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#3970 Signed-off-by: Masatake YAMATO <[email protected]>
Weeks later, FWIW, there's probably already regex-based syntax highlighting for Dockerfile
|
Close universal-ctags#3970 Signed-off-by: Masatake YAMATO <[email protected]>
FROM X AS Y is what you want to consider. There are implicit numerical names given. I do not see a great value in trying to add references from commands like Example FROM alpine:latest
# RUN ..
FROM debian:latest
# Here we copy from stage 0 (not given a symbolic name automatic name is 0)
COPY --from=0 /build/artifact /usr/local/bin
ENTRYPOINT ["/usr/local/bin/artifact"] |
STORY: Users can parse Dockerfile and Containerfile with universal-ctags in order to navigate and review with tool support.
man Containerfile
:https://github.com/containers/common/blob/main/docs/Containerfile.5.md
FROM
,RUN
,ARG
,ENV
,: https://docs.docker.com/reference/dockerfile/https://pkg.go.dev/github.com/distribution/reference#pkg-overview
https://docs.docker.com/reference/dockerfile/
parsers/
?https://docs.python.org/3/reference/grammar.html#full-grammar-specification
The text was updated successfully, but these errors were encountered: