Skip to content

Commit

Permalink
Merge pull request #217 from multiversx/feat-default-platform
Browse files Browse the repository at this point in the history
Set default platform by default + flag to skip setting it
  • Loading branch information
lcswillems authored Feb 7, 2023
2 parents a4ebde1 + 31292a8 commit 2b355ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion multiversx_sdk_cli/cli_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def setup_parser(args: List[str], subparsers: Any) -> Any:
sub.add_argument("--contract", type=str, help="relative path of the contract in the project")
sub.add_argument("--no-docker-interactive", action="store_true", default=False)
sub.add_argument("--no-docker-tty", action="store_true", default=False)
sub.add_argument("--no-default-platform", action="store_true", default=False,
help="do not set DOCKER_DEFAULT_PLATFORM environment variable to 'linux/amd64'")
sub.set_defaults(func=do_reproducible_build)

parser.epilog = cli_shared.build_group_epilog(subparsers)
Expand Down Expand Up @@ -441,6 +443,7 @@ def do_reproducible_build(args: Any):
contract_path = args.contract
docker_interactive = not args.no_docker_interactive
docker_tty = not args.no_docker_tty
no_default_platform = args.no_default_platform

project_path = Path(project_path).expanduser().resolve()
output_path = project_path / "output-docker"
Expand All @@ -455,7 +458,7 @@ def do_reproducible_build(args: Any):
raise DockerMissingError()

logger.info("Starting the docker run...")
run_docker(docker_image, project_path, contract_path, output_path, no_wasm_opt, docker_interactive, docker_tty)
run_docker(docker_image, project_path, contract_path, output_path, no_wasm_opt, docker_interactive, docker_tty, no_default_platform)

logger.info("Docker build ran successfully!")
logger.info(f"Inspect summary of generated artifacts here: {artifacts_path}")
Expand Down
4 changes: 4 additions & 0 deletions multiversx_sdk_cli/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def run_docker(
no_wasm_opt: bool,
docker_interactive: bool,
docker_tty: bool,
no_default_platform: bool
):
docker_mount_args: List[str] = ["--volume", f"{output_path}:/output"]

Expand All @@ -48,6 +49,9 @@ def run_docker(
docker_args += ["--user", f"{str(os.getuid())}:{str(os.getgid())}"]
docker_args += ["--rm", image]

if not(no_default_platform):
docker_args += ["--platform", "linux/amd64"]

entrypoint_args: List[str] = []

if project_path:
Expand Down

0 comments on commit 2b355ea

Please sign in to comment.