diff --git a/doc/changelog.md b/doc/changelog.md index 5d47db3b0..2996c8bb2 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -1,6 +1,7 @@ # ChangeLog * **0.45-SNAPSHOT**: - Automatically create parent directories of portPropertyFile path + - Added support for `platform` attribute of a container in the docker-compose configuration. * **0.44.0** (2024-02-17): - Add new option "useDefaultExclusion" for build configuration to handle exclusion of hidden files ([1708](https://github.com/fabric8io/docker-maven-plugin/issues/1708)) diff --git a/src/main/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeConfigHandler.java b/src/main/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeConfigHandler.java index 8000a7ec9..573b2d068 100644 --- a/src/main/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeConfigHandler.java +++ b/src/main/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeConfigHandler.java @@ -212,6 +212,7 @@ private RunImageConfiguration createRunConfiguration(DockerComposeServiceWrapper .labels(wrapper.getLabels()) .links(wrapper.getLinks()) // external_links and links are handled the same in d-m-p .log(wrapper.getLogConfiguration()) + .platform(wrapper.getPlatform()) .network(wrapper.getNetworkConfig()) // TODO: Up to now only a single network is supported and not ipv4, ipv6 // pid not supported .ports(wrapper.getPortMapping()) diff --git a/src/main/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeServiceWrapper.java b/src/main/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeServiceWrapper.java index 276ed7ef7..53a83f752 100644 --- a/src/main/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeServiceWrapper.java +++ b/src/main/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeServiceWrapper.java @@ -128,7 +128,11 @@ List getDependsOn() { boolean usesLongSyntaxDependsOn() { return asObject("depends_on") instanceof Map; } - + + public String getPlatform() { + return asString("platform"); + } + /** * Docker Compose Spec v2.1+ defined conditions */ diff --git a/src/test/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeConfigHandlerTest.java b/src/test/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeConfigHandlerTest.java index 8e1be8e90..44769222a 100644 --- a/src/test/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeConfigHandlerTest.java +++ b/src/test/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeConfigHandlerTest.java @@ -6,7 +6,6 @@ import io.fabric8.maven.docker.config.RunImageConfiguration; import io.fabric8.maven.docker.config.RunVolumeConfiguration; import io.fabric8.maven.docker.config.handler.ExternalConfigHandlerException; -import net.jodah.failsafe.internal.util.Assert; import org.apache.commons.io.FileUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; @@ -70,6 +69,15 @@ void simple() throws IOException, MavenFilteringException { validateRunConfiguration(configs.get(0).getRunConfiguration()); } + @Test + void simpleExtraIn24() throws IOException, MavenFilteringException { + setupComposeExpectations("docker-compose_2.4.yml"); + List configs = handler.resolve(unresolved, project, session); + Assertions.assertEquals(1, configs.size()); + RunImageConfiguration runConfig = configs.get(0).getRunConfiguration(); + Assertions.assertEquals("linux/amd64", runConfig.getPlatform()); + } + @Test void networkAliases() throws IOException, MavenFilteringException { setupComposeExpectations("docker-compose-network-aliases.yml"); @@ -266,7 +274,6 @@ void validateVolumeConfig(RunVolumeConfiguration toValidate) { * system */ private void assertHostBindingExists(String bindString) { - // System.err.println(">>>> " + bindString); // Extract the host-portion of the volume binding string, accounting for windows platform paths and unix style // paths. For example: diff --git a/src/test/resources/compose/docker-compose_2.4.yml b/src/test/resources/compose/docker-compose_2.4.yml new file mode 100644 index 000000000..bb0474d47 --- /dev/null +++ b/src/test/resources/compose/docker-compose_2.4.yml @@ -0,0 +1,5 @@ +version: 2.4 +services: + service: + image: image + platform: linux/amd64 \ No newline at end of file