Skip to content

Commit

Permalink
Expose Dockerfile path param to regenerate-configure script
Browse files Browse the repository at this point in the history
  • Loading branch information
hssyoo committed Jul 31, 2024
1 parent 297e130 commit 0887742
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions scripts/regenerate-configure/regenerate-configure
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
import argparse
import re
import time
from pathlib import Path
from subprocess import run

Expand All @@ -11,18 +10,18 @@ DOCKERFILE_PATH = ROOT / "scripts" / "regenerate-configure" / "Dockerfile"
IMAGE_RE = re.compile(r"sha256:(?P<image>.*?)\s")


def main(cleanup):
image = _build_image()
def main(dockerfile_path, cleanup):
image = _build_image(dockerfile_path)
container_id = _start_image(image)
_extract_configure_file(container_id)
if cleanup:
_cleanup_image_and_container(image, container_id)


def _build_image():
print(f"Building docker image from: {DOCKERFILE_PATH}")
def _build_image(dockerfile_path):
print(f"Building docker image from: {dockerfile_path}")
result = _docker(
["build", "-f", str(DOCKERFILE_PATH), ".", "--quiet"],
["build", "-f", dockerfile_path, ".", "--quiet"],
cwd=ROOT,
)
_assert_success(result)
Expand Down Expand Up @@ -73,11 +72,19 @@ def _assert_success(result):

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--dockerfile-path",
default=str(DOCKERFILE_PATH),
help="Path to Dockerfile to build.",
)
parser.add_argument(
"--no-cleanup",
action="store_true",
default=False,
help="Do not clean up docker image and container. Useful for debugging.",
)
args = parser.parse_args()
main(not args.no_cleanup)
main(
args.dockerfile_path,
not args.no_cleanup
)

0 comments on commit 0887742

Please sign in to comment.