Skip to content

Commit 471649c

Browse files
committed
Update testcontainers-advanced-imagebuilder to 2.0.1
1 parent 8841373 commit 471649c

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

testcontainers/Standalone.Dockerfile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# syntax=docker/dockerfile:1-labs
12
ARG JAVA_VERSION=21
23
FROM eclipse-temurin:${JAVA_VERSION}-jre-alpine AS jre-base
34

@@ -35,18 +36,27 @@ ENTRYPOINT ["/entrypoint.sh"]
3536

3637
FROM eclipse-temurin:${JAVA_VERSION}-jdk-alpine AS builder
3738

38-
RUN apk add --no-cache git bash
39+
RUN apk add --no-cache bash
3940

4041
WORKDIR /builder
4142

42-
# Copying context is prepared by Testcontainers
43-
COPY . ./
43+
# Copy & Cache wrapper
44+
COPY --parents mvnw .mvn/** ./
45+
RUN ./mvnw --version
4446

45-
ARG mvncmd='clean package -pl "server" -am -T2C -Dmaven.test.skip'
47+
# Copy & Cache poms/dependencies
48+
COPY --parents **/pom.xml ./
49+
# Resolve jars so that they can be cached and don't need to be downloaded when a Java file changes
50+
ARG MAVEN_GO_OFFLINE_COMMAND='./mvnw -B dependency:go-offline -pl server -am -DincludeScope=runtime -T2C'
51+
RUN echo "Executing '$MAVEN_GO_OFFLINE_COMMAND'"
52+
RUN ${MAVEN_GO_OFFLINE_COMMAND}
4653

47-
RUN echo "Executing '$mvncmd'"
48-
RUN chmod +x ./mvnw \
49-
&& ./mvnw -B ${mvncmd}
54+
# Copying all other files
55+
COPY . ./
56+
# Run the actual build
57+
ARG MAVEN_BUILD_COMMAND='./mvnw -B package -pl "server" -am -T2C -Dmaven.test.skip'
58+
RUN echo "Executing '$MAVEN_BUILD_COMMAND'"
59+
RUN ${MAVEN_BUILD_COMMAND}
5060

5161

5262
FROM jre-minimized

testcontainers/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<dependency>
8989
<groupId>software.xdev</groupId>
9090
<artifactId>testcontainers-advanced-imagebuilder</artifactId>
91-
<version>1.1.1</version>
91+
<version>2.0.1</version>
9292
<scope>test</scope>
9393
</dependency>
9494

testcontainers/src/test/java/software/xdev/testcontainers/mockserver/containers/MockServerContainerTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import software.xdev.mockserver.model.Format;
4141
import software.xdev.mockserver.model.HttpForward;
4242
import software.xdev.testcontainers.imagebuilder.AdvancedImageFromDockerFile;
43+
import software.xdev.testcontainers.imagebuilder.compat.DockerfileCOPYParentsEmulator;
4344

4445

4546
@SuppressWarnings("resource") // HttpClient close does not exist on Java 17!
@@ -52,7 +53,7 @@ static void buildImage()
5253
{
5354
image = DockerImageName.parse(new AdvancedImageFromDockerFile("mockserver")
5455
.withLoggerForBuild(LoggerFactory.getLogger("container.build.mockserver"))
55-
.withAdditionalIgnoreLines(
56+
.withPostGitIgnoreLines(
5657
// Ignore files that aren't related to the built code
5758
".git/**",
5859
".config/**",
@@ -61,13 +62,15 @@ static void buildImage()
6162
".run/**",
6263
"assets/**",
6364
"docs/**",
64-
".md",
65-
".cmd",
65+
"Dockerfile",
66+
"*.md",
67+
"*.cmd",
6668
"/renovate.json5",
6769
"/client/src/**",
6870
"/testcontainers/src/**")
6971
.withDockerFilePath(Paths.get("../testcontainers/Standalone.Dockerfile"))
7072
.withBaseDir(Paths.get("../"))
73+
.withDockerFileLinesModifier(new DockerfileCOPYParentsEmulator())
7174
.get());
7275
}
7376

0 commit comments

Comments
 (0)