Skip to content

Commit

Permalink
Create apifunc.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-sapletta-com authored Mar 29, 2024
1 parent 02b67fc commit 1261ab4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions apifunc.py
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)

0 comments on commit 1261ab4

Please sign in to comment.