From bca332b59834cb01ade589c2ae31ffdf2114ccbe Mon Sep 17 00:00:00 2001 From: VPhung24 Date: Mon, 7 Oct 2024 18:27:10 +0000 Subject: [PATCH] run dockerfile if exists --- stack_orchestrator/build/build_webapp.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/stack_orchestrator/build/build_webapp.py b/stack_orchestrator/build/build_webapp.py index 1021f4bf..5b349366 100644 --- a/stack_orchestrator/build/build_webapp.py +++ b/stack_orchestrator/build/build_webapp.py @@ -88,9 +88,17 @@ def command(ctx, base_container, source_repo, force_rebuild, extra_build_args, t # Now build the target webapp. We use the same build script, but with a different Dockerfile and work dir. container_build_env["CERC_WEBAPP_BUILD_RUNNING"] = "true" container_build_env["CERC_CONTAINER_BUILD_WORK_DIR"] = os.path.abspath(source_repo) - container_build_env["CERC_CONTAINER_BUILD_DOCKERFILE"] = os.path.join(container_build_dir, - base_container.replace("/", "-"), - "Dockerfile.webapp") + # Check if Dockerfile exists in the repository + repo_dockerfile = os.path.join(container_build_env["CERC_CONTAINER_BUILD_WORK_DIR"], "Dockerfile") + default_dockerfile = os.path.join(container_build_dir, + base_container.replace("/", "-"), + "Dockerfile.webapp") + + if os.path.isfile(repo_dockerfile): + container_build_env["CERC_CONTAINER_BUILD_DOCKERFILE"] = repo_dockerfile + else: + container_build_env["CERC_CONTAINER_BUILD_DOCKERFILE"] = default_dockerfile + if not tag: webapp_name = os.path.abspath(source_repo).split(os.path.sep)[-1] tag = f"cerc/{webapp_name}:local"