-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02b67fc
commit 1261ab4
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# apifunc.py | ||
def apifunc(dockerfile_path): | ||
instruction_mapping = { | ||
"FROM": "Base image", | ||
"RUN": "Commands", | ||
"ADD": "File additions", | ||
"ENV": "Environment variables", | ||
"ENTRYPOINT": "Entry point", | ||
"CMD": "Default command", | ||
} | ||
|
||
with open(dockerfile_path, "r") as f: | ||
for line in f: | ||
tokens = line.strip().split(maxsplit=1) | ||
if tokens: | ||
instruction = tokens[0] | ||
if instruction in instruction_mapping: | ||
details = tokens[1] if len(tokens) > 1 else "" | ||
print(f"{instruction_mapping[instruction]}: {details}") | ||
|
||
if __name__ == "__main__": | ||
dockerfile_path = "Dockerfile" | ||
parse_dockerfile(dockerfile_path) |