Skip to content

Commit

Permalink
Upgrade alpine images for better M1 compatibility (#4291)
Browse files Browse the repository at this point in the history
  • Loading branch information
rnorth authored Jul 20, 2021
1 parent 71314ab commit 3c614f2
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class DockerClientFactory {
TESTCONTAINERS_SESSION_ID_LABEL, SESSION_ID
);

private static final DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.5");
private static final DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.14");
private static DockerClientFactory instance;

// Cached client configuration
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/java/org/testcontainers/TestImages.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface TestImages {
DockerImageName REDIS_IMAGE = DockerImageName.parse("redis:3.0.2");
DockerImageName RABBITMQ_IMAGE = DockerImageName.parse("rabbitmq:3.5.3");
DockerImageName MONGODB_IMAGE = DockerImageName.parse("mongo:3.1.5");
DockerImageName ALPINE_IMAGE = DockerImageName.parse("alpine:3.2");
DockerImageName ALPINE_IMAGE = DockerImageName.parse("alpine:3.14");
DockerImageName DOCKER_REGISTRY_IMAGE = DockerImageName.parse("registry:2.7.0");
DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.5");
DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.14");
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public void shouldGetDependencyImagesWhenOverriding() {
Lists.newArrayList(new File("src/test/resources/docker-compose-imagename-overriding-a.yml"),
new File("src/test/resources/docker-compose-imagename-overriding-b.yml")));
Assertions.assertThat(dockerComposeFiles.getDependencyImages())
.containsExactlyInAnyOrder("alpine:3.2", "redis:b", "mysql:b", "aservice");
.containsExactlyInAnyOrder("alpine:3.14", "redis:b", "mysql:b", "aservice");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public void shouldObtainImageFromDockerfileBuild() {
.contains(
entry("mysql", Sets.newHashSet("mysql")),
entry("redis", Sets.newHashSet("redis")),
entry("custom", Sets.newHashSet("alpine:3.2")))
.as("all defined images are found"); // r/ redis, mysql from compose file, alpine:3.2 from Dockerfile build
entry("custom", Sets.newHashSet("alpine:3.14")))
.as("all defined images are found"); // r/ redis, mysql from compose file, alpine:3.14 from Dockerfile build
}

@Test
Expand All @@ -116,7 +116,7 @@ public void shouldObtainImageFromDockerfileBuildWithContext() {
.contains(
entry("mysql", Sets.newHashSet("mysql")),
entry("redis", Sets.newHashSet("redis")),
entry("custom", Sets.newHashSet("alpine:3.2")))
.as("all defined images are found"); // redis, mysql from compose file, alpine:3.2 from Dockerfile build
entry("custom", Sets.newHashSet("alpine:3.14")))
.as("all defined images are found"); // redis, mysql from compose file, alpine:3.14 from Dockerfile build
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ToStringConsumerTest {

@Test
public void newlines_are_not_added_to_exec_output() throws Exception {
try (GenericContainer<?> container = new GenericContainer<>("alpine:3.13")) {
try (GenericContainer<?> container = new GenericContainer<>("alpine:3.14")) {
container.withCommand("sleep", "2m");
container.start();

Expand All @@ -37,7 +37,7 @@ public void newlines_are_not_added_to_exec_output() throws Exception {

@Test(timeout = 60_000L)
public void newlines_are_not_added_to_exec_output_with_tty() throws Exception {
try (GenericContainer<?> container = new GenericContainer<>("alpine:3.13")) {
try (GenericContainer<?> container = new GenericContainer<>("alpine:3.14")) {
container.withCreateContainerCmdModifier(cmd -> {
cmd
.withAttachStdin(true)
Expand All @@ -56,7 +56,7 @@ public void newlines_are_not_added_to_exec_output_with_tty() throws Exception {

@Test
public void newlines_are_not_added_to_container_output() {
try (GenericContainer<?> container = new GenericContainer<>("alpine:3.13")) {
try (GenericContainer<?> container = new GenericContainer<>("alpine:3.14")) {
container.withCommand("echo", "-n", LARGE_PAYLOAD);
container.setStartupCheckStrategy(new OneShotStartupCheckStrategy());
container.start();
Expand All @@ -71,7 +71,7 @@ public void newlines_are_not_added_to_container_output() {

@Test
public void newlines_are_not_added_to_container_output_with_tty() {
try (GenericContainer<?> container = new GenericContainer<>("alpine:3.13")) {
try (GenericContainer<?> container = new GenericContainer<>("alpine:3.14")) {
container.withCreateContainerCmdModifier(cmd -> {
cmd.withTty(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ public class ImagePullTest {
public static String[] parameters() {
return new String[] {
"alpine:latest",
"alpine:3.6",
"alpine:3.14",
"alpine", // omitting the tag should work and default to latest
"alpine@sha256:8fd4b76819e1e5baac82bd0a3d03abfe3906e034cc5ee32100d12aaaf3956dc7",
"gliderlabs/alpine:latest",
"gliderlabs/alpine:3.5",
"gliderlabs/alpine@sha256:a19aa4a17a525c97e5a90a0c53a9f3329d2dc61b0a14df5447757a865671c085",
"alpine@sha256:1775bebec23e1f3ce486989bfc9ff3c4e951690df84aa9f926497d82f2ffca9d",
"quay.io/testcontainers/ryuk:latest",
"quay.io/testcontainers/ryuk:0.2.3",
"quay.io/testcontainers/ryuk@sha256:bb5a635cac4bd96c93cc476969ce11dc56436238ec7cd028d0524462f4739dd9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected void configure(BuildImageCmd buildImageCmd) {
super.configure(buildImageCmd);

List<String> dockerfile = Arrays.asList(
"FROM alpine:3.2",
"FROM alpine:3.14",
"RUN echo 'hello from Docker build process'",
"CMD yes"
);
Expand All @@ -59,7 +59,7 @@ public void dockerfileBuilderWorks() {
.withFileFromClasspath("test.txt", "mappable-resource/test-resource.txt")
.withFileFromString("folder/someFile.txt", "hello")
.withDockerfileFromBuilder(builder -> builder
.from("alpine:3.2")
.from("alpine:3.14")
.workDir("/app")
.add("test.txt", "test file.txt")
.run("ls", "-la", "/app/test file.txt")
Expand Down Expand Up @@ -101,7 +101,7 @@ public int getFileMode() {

})
.withDockerfileFromBuilder(builder -> builder
.from("alpine:3.2")
.from("alpine:3.14")
.copy("someFile.txt", "/someFile.txt")
.cmd("stat -c \"%a\" /someFile.txt")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class FixedHostPortContainerTest {

private static final String TEST_IMAGE = "alpine:3.2";
private static final String TEST_IMAGE = "alpine:3.14";

/**
* Default http server port (just something different from default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ public ParameterizedDockerfileContainerTest(String baseImage, String expectedVer
@Parameterized.Parameters(name = "{0}")
public static Object[][] data() {
return new Object[][] {
{ "alpine:3.2", "3.2"},
{ "alpine:3.3", "3.3"},
{ "alpine:3.4", "3.4"},
{ "alpine:3.5", "3.5"},
{ "alpine:3.6", "3.6"}
{ "alpine:3.12", "3.12"},
{ "alpine:3.13", "3.13"},
{ "alpine:3.14", "3.14"}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void simpleRecursiveFileTest() {
GenericContainer container = new GenericContainer(
new ImageFromDockerfile()
.withDockerfileFromBuilder(builder ->
builder.from("alpine:3.3")
builder.from("alpine:3.14")
.copy("/tmp/foo", "/foo")
.cmd("cat /foo/test/resources/test-recursive-file.txt")
.build()
Expand All @@ -45,7 +45,7 @@ public void simpleRecursiveFileWithPermissionTest() {
GenericContainer container = new GenericContainer(
new ImageFromDockerfile()
.withDockerfileFromBuilder(builder ->
builder.from("alpine:3.3")
builder.from("alpine:3.14")
.copy("/tmp/foo", "/foo")
.cmd("ls", "-al", "/")
.build()
Expand All @@ -68,7 +68,7 @@ public void simpleRecursiveClasspathResourceTest() {
GenericContainer container = new GenericContainer(
new ImageFromDockerfile()
.withDockerfileFromBuilder(builder ->
builder.from("alpine:3.3")
builder.from("alpine:3.14")
.copy("/tmp/foo", "/foo")
.cmd("ls -lRt /foo")
.build()
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/resources/compose-dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM alpine:3.2
FROM alpine:3.14

ADD passthrough.sh /passthrough.sh

CMD /passthrough.sh
CMD /passthrough.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ services:
redis:
image: redis
other:
image: alpine:3.5
image: alpine:3.14
command: sleep 10000
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM alpine:3.2
FROM alpine:3.14
2 changes: 1 addition & 1 deletion core/src/test/resources/dockerfile-build-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM alpine:3.2
FROM alpine:3.14
COPY localfile.txt /test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM alpine:3.2
FROM alpine:3.14
RUN echo "test4567" > /test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM alpine:3.2
FROM alpine:3.14
ARG CUSTOM_ARG
RUN echo "${CUSTOM_ARG}" > /test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM alpine:3.2
FROM alpine:3.14
COPY . /
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.7
FROM alpine:3.14

HEALTHCHECK --interval=1s CMD test -e /testfile

Expand Down
4 changes: 2 additions & 2 deletions core/src/test/resources/mappable-dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.2
FROM alpine:3.14
ADD folder/someFile.txt /someFile.txt
RUN cat /someFile.txt
ADD test.txt /test.txt
RUN cat /test.txt
CMD ping -c 5 www.google.com
CMD ping -c 5 www.google.com
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ContainerCreationTest {
.withExposedPorts(6379);
// }

public static final DockerImageName ALPINE_IMAGE = DockerImageName.parse("alpine:3.2");
public static final DockerImageName ALPINE_IMAGE = DockerImageName.parse("alpine:3.14");

// withOptions {
// Set up a plain OS container and customize environment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class ContainerLabelTest {
// single_label {
public GenericContainer containerWithLabel = new GenericContainer(DockerImageName.parse("alpine:3.6"))
public GenericContainer containerWithLabel = new GenericContainer(DockerImageName.parse("alpine:3.14"))
.withLabel("key", "value");
// }

Expand All @@ -17,7 +17,7 @@ public class ContainerLabelTest {
private Map<String, String> mapOfLabels = new HashMap<>();
// populate map, e.g. mapOfLabels.put("key1", "value1");

public GenericContainer containerWithMultipleLabels = new GenericContainer(DockerImageName.parse("alpine:3.6"))
public GenericContainer containerWithMultipleLabels = new GenericContainer(DockerImageName.parse("alpine:3.14"))
.withLabels(mapOfLabels);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class ExecTest {

@Rule
public GenericContainer<?> container = new GenericContainer<>(DockerImageName.parse("alpine:3.6"))
public GenericContainer<?> container = new GenericContainer<>(DockerImageName.parse("alpine:3.14"))
.withCommand("top");

@Test
Expand Down
2 changes: 1 addition & 1 deletion docs/features/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Some companies disallow the usage of Docker Hub, but you can override `*.image`
> **ryuk.container.image = testcontainers/ryuk:0.3.1**
> Performs fail-safe cleanup of containers, and always required (unless [Ryuk is disabled](#disabling-ryuk))
> **tinyimage.container.image = alpine:3.5**
> **tinyimage.container.image = alpine:3.14**
> Used to check whether images can be pulled at startup, and always required (unless [startup checks are disabled](#disabling-the-startup-checks))
> **sshd.container.image = testcontainers/sshd:1.0.0**
Expand Down
2 changes: 1 addition & 1 deletion docs/features/creating_images.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ new GenericContainer(
new ImageFromDockerfile()
.withDockerfileFromBuilder(builder ->
builder
.from("alpine:3.2")
.from("alpine:3.14")
.run("apk add --update nginx")
.cmd("nginx", "-g", "daemon off;")
.build()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ interface SpockTestImages {
DockerImageName MYSQL_IMAGE = DockerImageName.parse("mysql:5.7.34")
DockerImageName POSTGRES_TEST_IMAGE = DockerImageName.parse("postgres:9.6.12")
DockerImageName HTTPD_IMAGE = DockerImageName.parse("httpd:2.4-alpine")
DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.5")
DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.14")
}

0 comments on commit 3c614f2

Please sign in to comment.