Skip to content

Commit

Permalink
Merge pull request #319 from KyleAure/317-arm-images
Browse files Browse the repository at this point in the history
Update container images to those that support the ARM architecture
  • Loading branch information
appiepollo14 authored Nov 15, 2023
2 parents 424d499 + 029a9f9 commit d227949
Show file tree
Hide file tree
Showing 29 changed files with 173 additions and 79 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ mvn clean install

NOTE: The first run will take longer due to downloading required container layers. Subsequent runs will be faster.

NOTE: If a container is consistantly timing out on your system you can set a longer timeout (in seconds) with the system property
`microshed.testing.startup.timeout` default value is 60 seconds.

NOTE: If a mockserver has started, but HTTP calls are consistantly timint out on your system you can set a longer timeout (in milliseconds)
with the system property `mockserver.maxSocketTimeout` default value is 120000 milliseconds.

### Tested with:
- OpenLiberty
- Wildfly
Expand Down
2 changes: 1 addition & 1 deletion docs/features/SupportedRuntimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Maven Dependency:
Example Dockerfile:

```
FROM jboss/wildfly
FROM quay.io/wildfly/wildfly:26.1.2.Final-jdk11
ADD build/libs/myservice.war /opt/jboss/wildfly/standalone/deployments/
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Payara Services Corporation and others
* Copyright (c) 2019, 2023 Payara Services Corporation and others
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -48,6 +48,8 @@ public ImageFromDockerfile getDefaultImage(File appFile) {
// FROM payara/micro:5.2022.5-jdk11
// CMD ["--deploymentDir", "/opt/payara/deployments", "--noCluster"]
// ADD target/myservice.war /opt/payara/deployments/
//FIXME - update to newer payara version once multi-platform docker images are available
//See issue: https://github.com/payara/Payara/issues/5715
ImageFromDockerfile image = new ImageFromDockerfile()
.withDockerfileFromBuilder(builder -> builder.from("payara/micro:5.2022.5-jdk11")
.cmd("--deploymentDir", "/opt/payara/deployments/", "--noCluster")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Payara Services Corporation and others
* Copyright (c) 2019, 2023 Payara Services Corporation and others
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -47,6 +47,8 @@ public ImageFromDockerfile getDefaultImage(File appFile) {
// Compose a docker image equivalent to doing:
// FROM payara/server-full:5.2022.5-jdk11
// ADD target/myservice.war /opt/payara/deployments/
//FIXME - update to newer payara version once multi-platform docker images are available
//See issue: https://github.com/payara/Payara/issues/5715
ImageFromDockerfile image = new ImageFromDockerfile()
.withDockerfileFromBuilder(builder -> builder.from("payara/server-full:5.2022.5-jdk11")
.add(appName, "/opt/payara/deployments/")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 IBM Corporation and others
* Copyright (c) 2020, 2023 IBM Corporation and others
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -141,7 +141,7 @@ private void autoConfigureJwt() {
}

private void autoConfigureDatabases() {
if (System.getProperty("quarkus.datasource.url") != null ||
if (System.getProperty("quarkus.datasource.jdbc.url") != null ||
System.getProperty("quarkus.datasource.username") != null ||
System.getProperty("quarkus.datasource.password") != null)
return; // Do not override explicit configuration
Expand All @@ -153,10 +153,10 @@ private void autoConfigureDatabases() {
if (jdbcContainers.size() == 1) {
GenericContainer<?> db = jdbcContainers.get(0);
String jdbcUrl = (String) JdbcContainerClass.getMethod("getJdbcUrl").invoke(db);
System.setProperty("quarkus.datasource.url", jdbcUrl);
System.setProperty("quarkus.datasource.jdbc.url", jdbcUrl);
System.setProperty("quarkus.datasource.username", (String) JdbcContainerClass.getMethod("getUsername").invoke(db));
System.setProperty("quarkus.datasource.password", (String) JdbcContainerClass.getMethod("getPassword").invoke(db));
LOG.info("Set quarkus.datasource.url to: " + jdbcUrl);
LOG.info("Set quarkus.datasource.jdbc.url to: " + jdbcUrl);
} else if (jdbcContainers.size() > 1) {
LOG.info("Located multiple JdbcDatabaseContainer instances. Unable to auto configure quarkus.datasource.* properties");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.microshed.testing.testcontainers.ApplicationContainer;
import org.testcontainers.containers.MockServerContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.utility.DockerImageName;

@MicroShedTest
public class TestcontainersConfigurationIT {
Expand All @@ -46,8 +47,12 @@ public class TestcontainersConfigurationIT {
.withEnv("SVC_URL6", oldValue -> "http://mockserver:1080")
.withMpRestClient("com.foo.ExampleClass", "http://mockserver:1080");

private static final DockerImageName MOCK_SERVER_IMAGE_NAME =
DockerImageName.parse("mockserver/mockserver:5.15.0")
.asCompatibleSubstituteFor("jamesdbloom/mockserver");

@Container
public static MockServerContainer mockServer = new MockServerContainer()
public static MockServerContainer mockServer = new MockServerContainer(MOCK_SERVER_IMAGE_NAME)
.withNetworkAliases("mockserver")
.withEnv("STAYS_UNCHANGED", "mockserver");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 IBM Corporation and others
* Copyright (c) 2019, 2023 IBM Corporation and others
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -20,6 +20,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
import java.util.Map;
Expand Down Expand Up @@ -95,22 +96,26 @@ public void testPrimaryPort() {
ApplicationContainer app = dummyApp()
.withHttpPort(8888)
.withExposedPorts(7777, 9999);
assertEquals(Arrays.asList(8888, 7777, 9999), app.getExposedPorts());
assertEquals(8888, app.getFirstMappedPort());
assertTrue(app.getExposedPorts().containsAll(Arrays.asList(8888, 7777, 9999)));

app = dummyApp()
.withExposedPorts(1234, 1235)
.withHttpPort(4444);
assertEquals(Arrays.asList(4444, 1234, 1235), app.getExposedPorts());
assertEquals(4444, app.getFirstMappedPort());
assertTrue(app.getExposedPorts().containsAll(Arrays.asList(4444, 1234, 1235)));

app = dummyApp();
app.withHttpPort(5555);
app.setExposedPorts(Arrays.asList(1238, 1239));
assertEquals(Arrays.asList(5555, 1238, 1239), app.getExposedPorts());
assertEquals(5555, app.getFirstMappedPort());
assertTrue(app.getExposedPorts().containsAll(Arrays.asList(5555, 1238, 1239)));

app = dummyApp()
.withHttpPort(9081)
.withExposedPorts(9081, 9444);
assertEquals(Arrays.asList(9081, 9444), app.getExposedPorts());
assertEquals(9081, app.getFirstMappedPort());
assertTrue(app.getExposedPorts().containsAll(Arrays.asList(9081, 9444)));
}

public static ApplicationContainer dummyApp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.testcontainers.containers.wait.strategy.WaitStrategy;
import org.testcontainers.containers.wait.strategy.WaitStrategyTarget;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.utility.DockerImageName;

@MicroShedTest
public class HollowTestcontainersConfigurationTest {
Expand Down Expand Up @@ -63,8 +64,12 @@ public void waitUntilReady(WaitStrategyTarget waitStrategyTarget) {
}
});

private static final DockerImageName MOCK_SERVER_IMAGE_NAME =
DockerImageName.parse("mockserver/mockserver:5.15.0")
.asCompatibleSubstituteFor("jamesdbloom/mockserver");

@Container
public static MockServerContainer mockServer = new MockServerContainer()
public static MockServerContainer mockServer = new MockServerContainer(MOCK_SERVER_IMAGE_NAME)
.withNetworkAliases("mockserver")
.withEnv("STAYS_UNCHANGED", "mockserver");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Philip Riecks
* Copyright (c) 2020, 2023 Philip Riecks
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -44,14 +44,14 @@ public int getDefaultHttpsPort() {
public ImageFromDockerfile getDefaultImage(File appFile) {
String appName = appFile.getName();
// Compose a docker image equivalent to doing:
// FROM jboss/wildfly:18.0.1.Final
// FROM quay.io/wildfly/wildfly:26.1.2.Final-jdk11
// ADD target/myservice.war /opt/jboss/wildfly/standalone/deployments/
ImageFromDockerfile image = new ImageFromDockerfile()
.withDockerfileFromBuilder(builder -> builder.from("jboss/wildfly:18.0.1.Final")
.withDockerfileFromBuilder(builder -> builder
.from("quay.io/wildfly/wildfly:26.1.2.Final-jdk11")
.add(appName, "/opt/jboss/wildfly/standalone/deployments/")
.build())
.withFileFromFile(appName, appFile);
return image;

}
}
2 changes: 1 addition & 1 deletion sample-apps/everything-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COPY src/main/liberty/config /config/
ADD build/libs/myservice.war /config/dropins/

# Wildfly
#FROM jboss/wildfly
#FROM quay.io/wildfly/wildfly:26.1.2.Final-jdk11
#ADD build/libs/myservice.war /opt/jboss/wildfly/standalone/deployments/

# Payara
Expand Down
12 changes: 8 additions & 4 deletions sample-apps/everything-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ plugins {
dependencies {
providedCompile 'javax:javaee-api:8.0.1'
providedCompile 'org.eclipse.microprofile:microprofile:2.1'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.11.2'

compile 'org.mongodb:mongo-java-driver:3.11.2'

testCompile project(':microshed-testing-testcontainers')
testCompile project(':microshed-testing-core')
testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.36'

testCompile 'org.slf4j:slf4j-log4j12:1.7.36'
testCompile 'org.testcontainers:mockserver:1.19.1'
testCompile 'org.mock-server:mockserver-client-java:5.5.4'
testCompile 'io.rest-assured:rest-assured:4.5.1'
testCompile 'org.mock-server:mockserver-client-java:5.15.0'
testCompile 'io.rest-assured:rest-assured:5.3.2'

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,43 @@
*/
package org.example.app;

import java.time.Duration;

import org.microshed.testing.SharedContainerConfiguration;
import org.microshed.testing.testcontainers.ApplicationContainer;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.MockServerContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.utility.DockerImageName;

public class AppContainerConfig implements SharedContainerConfiguration {

public static final Duration TIMEOUT = Duration.ofSeconds(
Long.parseLong(
System.getProperty("microshed.testing.startup.timeout", "60")
)
);

@Container
public static ApplicationContainer app = new ApplicationContainer()
.withAppContextRoot("/myservice")
.withEnv("MONGO_HOSTNAME", "testmongo")
.withEnv("MONGO_PORT", "27017")
.withMpRestClient(ExternalRestServiceClient.class, "http://mockserver:" + MockServerContainer.PORT);

private static final DockerImageName MOCK_SERVER_IMAGE_NAME =
DockerImageName.parse("mockserver/mockserver:5.15.0")
.asCompatibleSubstituteFor("jamesdbloom/mockserver");

@Container
public static MockServerContainer mockServer = new MockServerContainer()
.withNetworkAliases("mockserver");
public static MockServerContainer mockServer = new MockServerContainer(MOCK_SERVER_IMAGE_NAME)
.withNetworkAliases("mockserver")
.withStartupTimeout(TIMEOUT);

@Container
public static GenericContainer<?> mongo = new GenericContainer<>("mongo:3.4")
.withNetworkAliases("testmongo");
.withNetworkAliases("testmongo")
.withStartupTimeout(TIMEOUT);

@Override
public void startContainers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
import org.microshed.testing.jaxrs.RESTClient;
import org.microshed.testing.jupiter.MicroShedTest;
import org.mockserver.client.MockServerClient;

import com.google.common.net.MediaType;
import org.mockserver.model.MediaType;

@SuppressWarnings("resource")

Expand Down
2 changes: 1 addition & 1 deletion sample-apps/everything-jakarta-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COPY src/main/liberty/config /config/
ADD build/libs/myservice.war /config/dropins/

# Wildfly
#FROM jboss/wildfly
#FROM quay.io/wildfly/wildfly:26.1.2.Final-jdk11
#ADD build/libs/myservice.war /opt/jboss/wildfly/standalone/deployments/

# Payara
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.example.app;

import java.time.Duration;

import org.microshed.testing.SharedContainerConfiguration;
import org.microshed.testing.testcontainers.ApplicationContainer;
import org.testcontainers.containers.GenericContainer;
Expand All @@ -27,22 +29,32 @@

public class AppContainerConfig implements SharedContainerConfiguration {

public static final Duration TIMEOUT = Duration.ofSeconds(
Long.parseLong(
System.getProperty("microshed.testing.startup.timeout", "60")
)
);

@Container
public static ApplicationContainer app = new ApplicationContainer()
.withAppContextRoot("/myservice")
.withEnv("MONGO_HOSTNAME", "testmongo")
.withEnv("MONGO_PORT", "27017")
.withMpRestClient(ExternalRestServiceClient.class, "http://mockserver:" + MockServerContainer.PORT);

private static DockerImageName mockServerImage = DockerImageName.parse("mockserver/mockserver:5.15.0").asCompatibleSubstituteFor("jamesdbloom/mockserver");
private static final DockerImageName MOCK_SERVER_IMAGE_NAME =
DockerImageName.parse("mockserver/mockserver:5.15.0")
.asCompatibleSubstituteFor("jamesdbloom/mockserver");

@Container
public static MockServerContainer mockServer = new MockServerContainer(mockServerImage)
.withNetworkAliases("mockserver");
public static MockServerContainer mockServer = new MockServerContainer(MOCK_SERVER_IMAGE_NAME)
.withNetworkAliases("mockserver")
.withStartupTimeout(TIMEOUT);

@Container
public static GenericContainer<?> mongo = new GenericContainer<>("mongo:3.4")
.withNetworkAliases("testmongo");
.withNetworkAliases("testmongo")
.withStartupTimeout(TIMEOUT);

@Override
public void startContainers() {
Expand Down
6 changes: 5 additions & 1 deletion sample-apps/kafka-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ dependencies {
providedCompile 'javax:javaee-api:8.0.1'
providedCompile 'org.eclipse.microprofile:microprofile:3.3'
providedCompile 'org.eclipse.microprofile.reactive.messaging:microprofile-reactive-messaging-api:1.0'
compile 'org.apache.kafka:kafka-clients:2.4.0'

compile 'org.apache.kafka:kafka-clients:3.6.0'

testCompile project(':microshed-testing-testcontainers')
testCompile project(':microshed-testing-core')

testCompile 'org.awaitility:awaitility:4.0.2'
testCompile 'org.testcontainers:kafka:1.15.0'
testCompile 'org.slf4j:slf4j-log4j12:1.7.36'

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
}

Expand Down
Loading

0 comments on commit d227949

Please sign in to comment.