diff --git a/agent/builder.py b/agent/builder.py index 918560a6..b4e9aa5c 100644 --- a/agent/builder.py +++ b/agent/builder.py @@ -30,6 +30,7 @@ def __init__( no_cache: bool, no_push: bool, registry: dict, + platform: str, ) -> None: super().__init__() @@ -37,6 +38,7 @@ def __init__( self.image_repository = image_repository self.image_tag = image_tag self.registry = registry + self.platform = platform # Build context, params self.filename = filename @@ -108,7 +110,7 @@ def _build_image(self): return {"output": self.output["build"]} def _get_build_command(self) -> str: - command = "docker buildx build --platform linux/amd64" + command = f"docker buildx build --platform {self.platform}" command = f"{command} -t {self._get_image_name()}" if self.no_cache: diff --git a/agent/web.py b/agent/web.py index c1a85efb..2bdde767 100644 --- a/agent/web.py +++ b/agent/web.py @@ -178,6 +178,7 @@ def build_image(): no_cache=data.get("no_cache"), no_push=data.get("no_push"), registry=data.get("registry"), + platform=data.get("platform", "linux/amd64"), ) job = image_builder.run_remote_builder() return {"job": job} @@ -550,7 +551,10 @@ def backup_site(bench, site): return {"job": job} -@application.route("/benches//sites//database/schema", methods=["POST"]) +@application.route( + "/benches//sites//database/schema", + methods=["POST"], +) @validate_bench_and_site def fetch_database_table_schema(bench, site): data = request.json or {} @@ -568,7 +572,10 @@ def fetch_database_table_schema(bench, site): return {"job": job} -@application.route("/benches//sites//database/query/execute", methods=["POST"]) +@application.route( + "/benches//sites//database/query/execute", + methods=["POST"], +) @validate_bench_and_site def run_sql(bench, site): query = request.json.get("query") @@ -596,6 +603,9 @@ def analyze_slow_queries(bench: str, site: str): @application.route("/benches//sites//database/users", methods=["POST"]) + "/benches//sites//database/users", + methods=["POST"], +) @validate_bench_and_site def create_database_user(bench, site): data = request.json @@ -609,7 +619,8 @@ def create_database_user(bench, site): @application.route( - "/benches//sites//database/users/", methods=["DELETE"] + "/benches//sites//database/users/", + methods=["DELETE"], ) @validate_bench_and_site def remove_database_user(bench, site, db_user): @@ -630,7 +641,10 @@ def update_database_permissions(bench, site, db_user): .benches[bench] .sites[site] .modify_database_user_permissions_job( - db_user, data["mode"], data.get("permissions", {}), data["mariadb_root_password"] + db_user, + data["mode"], + data.get("permissions", {}), + data["mariadb_root_password"], ) ) return {"job": job} @@ -1344,7 +1358,10 @@ def site_not_found(e): @application.route("/docker_cache_utils/", methods=["POST"]) def docker_cache_utils(method: str): - from agent.docker_cache_utils import get_cached_apps, run_command_in_docker_cache + from agent.docker_cache_utils import ( + get_cached_apps, + run_command_in_docker_cache, + ) if method == "run_command_in_docker_cache": return run_command_in_docker_cache(**request.json)