File tree Expand file tree Collapse file tree 3 files changed +24
-11
lines changed
src/test/java/software/xdev/testcontainers/mockserver/containers Expand file tree Collapse file tree 3 files changed +24
-11
lines changed Original file line number Diff line number Diff line change 1+ # syntax=docker/dockerfile:1-labs
12ARG JAVA_VERSION=21
23FROM eclipse-temurin:${JAVA_VERSION}-jre-alpine AS jre-base
34
@@ -35,18 +36,27 @@ ENTRYPOINT ["/entrypoint.sh"]
3536
3637FROM 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
4041WORKDIR /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
5262FROM jre-minimized
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 4040import software .xdev .mockserver .model .Format ;
4141import software .xdev .mockserver .model .HttpForward ;
4242import 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
You can’t perform that action at this time.
0 commit comments