Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support platform in external docker-compose config #1786

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ List<String> getDependsOn() {
boolean usesLongSyntaxDependsOn() {
return asObject("depends_on") instanceof Map;
}


public String getPlatform() {
return asString("platform");
}

/**
* <a href="https://docs.docker.com/compose/compose-file/compose-file-v2/#depends_on">Docker Compose Spec v2.1+ defined conditions</a>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ImageConfiguration> 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");
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/compose/docker-compose_2.4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 2.4
services:
service:
image: image
platform: linux/amd64
Loading