Skip to content

Commit 9e9cd35

Browse files
committed
feat: add support for building the image with a different architecture than the build environment
1 parent 95d11af commit 9e9cd35

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Build/BuildContainerImageStep.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ public function perform(string $environment, ProjectConfiguration $projectConfig
7474
throw new RuntimeException('Unable to find a "Dockerfile" to build the container image');
7575
}
7676

77-
$this->dockerExecutable->build($dockerfileName, sprintf('%s:%s', $projectConfiguration->getProjectName(), $environment), $this->buildDirectory);
77+
$this->dockerExecutable->build($dockerfileName, sprintf('%s:%s', $projectConfiguration->getProjectName(), $environment), $projectConfiguration->getEnvironmentArchitecture($environment), $this->buildDirectory);
7878
}
7979
}

src/Executable/DockerExecutable.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ class DockerExecutable extends AbstractExecutable
2020
/**
2121
* Build a docker image.
2222
*/
23-
public function build(string $file, string $tag, ?string $cwd = null)
23+
public function build(string $file, string $tag, string $architecture = '', ?string $cwd = null)
2424
{
25-
$this->run(sprintf('build --pull --file=%s --tag=%s .', $file, $tag), $cwd, null);
25+
$platform = 'linux/amd64';
26+
27+
if ('arm64' === $architecture) {
28+
$platform = 'linux/arm64';
29+
}
30+
31+
$this->run(sprintf('build --pull --file=%s --platform=%s --tag=%s .', $file, $platform, $tag), $cwd, null);
2632
}
2733

2834
/**

0 commit comments

Comments
 (0)