Skip to content

Commit 93f8a10

Browse files
authored
Merge pull request #128 from xdev-software/develop
Release
2 parents fc80373 + 067b0db commit 93f8a10

37 files changed

+3092
-331
lines changed

.gitignore

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,37 @@
11
# Maven
22
target/
3-
pom.xml.tag
4-
pom.xml.releaseBackup
5-
pom.xml.versionsBackup
6-
pom.xml.next
7-
release.properties
83
dependency-reduced-pom.xml
9-
buildNumber.properties
10-
.mvn/timing.properties
11-
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
4+
5+
# Maven Wrapper
126
.mvn/wrapper/maven-wrapper.jar
137

8+
# Maven Flatten Plugin
9+
.flattened-pom.xml
1410

1511
# Compiled class file
1612
*.class
1713

1814
# Log file
1915
*.log
2016

21-
# BlueJ files
22-
*.ctxt
23-
24-
# Mobile Tools for Java (J2ME)
25-
.mtj.tmp/
26-
2717
# Package/Binary Files don't belong into a git repo
2818
*.jar
2919
*.war
30-
*.nar
3120
*.ear
3221
*.zip
3322
*.tar.gz
34-
*.rar
3523
*.dll
3624
*.exe
3725
*.bin
3826

3927
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
4028
hs_err_pid*
4129

42-
# JRebel
43-
**/resources/rebel.xml
44-
**/resources/rebel-remote.xml
45-
46-
# eclispe stuff for root
47-
/.settings/
48-
/.classpath
49-
/.project
50-
51-
52-
# eclispe stuff for modules
53-
/*/.metadata/
54-
/*/.apt_generated_tests/
55-
/*/.settings/
56-
/*/.classpath
57-
/*/.project
58-
/*/RemoteSystemsTempFiles/
59-
60-
#custom
61-
.flattened-pom.xml
62-
.tern-project
30+
# Eclipse
31+
.metadata
32+
.settings
33+
.classpath
34+
.project
6335

6436
# == IntelliJ ==
6537
*.iml

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
# 2.0.0
2+
* Changed ignore backend to utilize [JGit](https://github.com/eclipse-jgit/jgit)
3+
* This should now behave exactly like a ``.gitignore``
4+
* Overall performance should be a lot faster
5+
* Make it possible to modify transferred files
6+
* Provide an option to emulate [``COPY --parents``](https://docs.docker.com/reference/dockerfile/#copy---parents) (which is currently not supported by Docker out of the box)
7+
* This option is required to utilize Docker's cache properly
8+
```docker
9+
# ...
10+
11+
# Copy & Cache wrapper
12+
COPY --parents mvnw .mvn/** ./
13+
RUN ./mvnw --version
14+
15+
# Copy & Cache poms/dependencies
16+
COPY --parents **/pom.xml ./
17+
# Resolve jars so that they can be cached and don't need to be downloaded when a Java file changes
18+
RUN ./mvnw -B dependency:go-offline -pl app -am -DincludeScope=runtime -T2C
19+
20+
# Copying all other files
21+
COPY . ./
22+
# Run the actual build
23+
RUN ./mvnw -B clean package -pl app -am -T2C -Dmaven.test.skip
24+
```
25+
* At ton of minor optimizations and improvements
26+
127
# 1.2.0
228
* Provide an option to always transfer specific paths
329
* Always transfer Dockerfile - as it is required for building - by default

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
identification within third-party archives.
188188

189189
Copyright 2024 XDEV Software
190+
Copyright 2023 Java Git Contributors
190191

191192
Licensed under the Apache License, Version 2.0 (the "License");
192193
you may not use this file except in compliance with the License.

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ A re-implementation of [Testcontainers Image-Builder](https://java.testcontainer
88
* Allows passing a custom logger to the image build - [testcontainers-java#3093](https://github.com/testcontainers/testcontainers-java/issues/3093)
99
* Allows using ``ARG``s for ``FROM`` - [testcontainers-java#3238](https://github.com/testcontainers/testcontainers-java/issues/3238)
1010
* Brings a custom [build-context](https://docs.docker.com/build/building/context/) processor
11-
* Works more efficient and reliable than the default implementation (however likely still not perfect)
12-
* uses ``.gitignore`` if available
11+
* Works more efficient and reliable than the default implementation because it utilizes [JGit](https://github.com/eclipse-jgit/jgit)
12+
* uses the ``.gitignore`` if available
1313
* Allows adding custom ignores
1414
* This way the build-context can be fine tuned in a way that the build cache works very efficiently (e.g. only re-built when actual code that matters changes)
15+
* Makes it possible to modify files that are transferred
16+
* Provide a compatibility layer to emulate [``COPY --parents``](https://docs.docker.com/reference/dockerfile/#copy---parents) (which is currently not supported by Docker out of the box)
1517
* Do not pull images that are declared inside the Dockerfile
1618
* Makes logger non generic and therefore controllable
17-
* Did some general code cleanup
19+
* Some general code cleanup and performance improvements
1820

1921
A common use case - that can also be seen [inside the demo](./testcontainers-advanced-imagebuilder-demo/src/main/java/software/xdev/Application.java) - is for creating an image - used in e.g. Integration tests - for an application that is also inside the same repo.
2022

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>testcontainers-advanced-imagebuilder-root</artifactId>
9-
<version>1.2.1-SNAPSHOT</version>
9+
<version>2.0.0-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<organization>

testcontainers-advanced-imagebuilder-demo/Dockerfile

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1+
# syntax=docker/dockerfile:1-labs
12
# Stage 1: Build the dummy app
23
ARG JAVA_VERSION=21
34
FROM eclipse-temurin:$JAVA_VERSION-jdk-alpine AS build-env
45

56
RUN apk add --no-cache git bash
67

7-
# Create non root user
8-
ARG userName=limitedbuild
9-
ARG groupName=limitedbuild
10-
ARG userId=1000
11-
12-
RUN addgroup --system ${groupName} \
13-
&& adduser --uid ${userId} --system --disabled-password --shell /bin/bash ${userName} \
14-
&& adduser ${userName} ${groupName}
15-
16-
# Create build dir
17-
RUN mkdir /build \
18-
&& chown ${userName}:${groupName} /build
198
WORKDIR /build
209

21-
USER ${userName}
22-
23-
# Copying context is prepared by Testcontainers
24-
COPY --chown=${userName}:${groupName} . ./
25-
26-
# RUN chmod +x ./mvnw
27-
ARG mvncmd='clean package -pl "testcontainers-advanced-imagebuilder-dummy-app" -am -T2C -Dmaven.test.skip'
28-
29-
RUN echo "Executing '$mvncmd'"
30-
RUN chmod +x ./mvnw \
31-
&& ./mvnw -B ${mvncmd}
10+
# Copy & Cache wrapper
11+
COPY --parents mvnw .mvn/** ./
12+
RUN ./mvnw --version
13+
14+
# Copy & Cache poms/dependencies
15+
COPY --parents **/pom.xml ./
16+
# Resolve jars so that they can be cached and don't need to be downloaded when a Java file changes
17+
ARG MAVEN_GO_OFFLINE_COMMAND='./mvnw -B dependency:go-offline -pl "testcontainers-advanced-imagebuilder-dummy-app" -am -DincludeScope=runtime -T2C'
18+
RUN echo "Executing '$MAVEN_GO_OFFLINE_COMMAND'"
19+
RUN ${MAVEN_GO_OFFLINE_COMMAND}
20+
21+
# Copying all other files
22+
COPY . ./
23+
24+
# A valid Git repo is required for the build
25+
RUN git config --global user.email "[email protected]" \
26+
&& git config --global user.name "Dynamic Build" \
27+
&& git init --initial-branch=dynamically-built-tcst \
28+
&& git add . \
29+
&& git commit -m "Init commit"
30+
31+
ARG MAVEN_BUILD_COMMAND='./mvnw -B clean package -pl "testcontainers-advanced-imagebuilder-dummy-app" -am -T2C -Dmaven.test.skip'
32+
RUN echo "Executing '$MAVEN_BUILD_COMMAND'"
33+
RUN ${MAVEN_BUILD_COMMAND}
3234

3335
# Stage 2: Build the executable image
3436
FROM eclipse-temurin:21-jre-alpine

testcontainers-advanced-imagebuilder-demo/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<parent>
88
<groupId>software.xdev</groupId>
99
<artifactId>testcontainers-advanced-imagebuilder-root</artifactId>
10-
<version>1.2.1-SNAPSHOT</version>
10+
<version>2.0.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>testcontainers-advanced-imagebuilder-demo</artifactId>
14-
<version>1.2.1-SNAPSHOT</version>
14+
<version>2.0.0-SNAPSHOT</version>
1515
<packaging>jar</packaging>
1616

1717
<organization>

testcontainers-advanced-imagebuilder-demo/src/main/java/software/xdev/Application.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.slf4j.LoggerFactory;
66

77
import software.xdev.testcontainers.imagebuilder.AdvancedImageFromDockerFile;
8+
import software.xdev.testcontainers.imagebuilder.compat.DockerfileCOPYParentsEmulator;
89

910

1011
public final class Application
@@ -14,7 +15,7 @@ public static void main(final String[] args)
1415
{
1516
final AdvancedImageFromDockerFile builder = new AdvancedImageFromDockerFile("dynamically-built")
1617
.withLoggerForBuild(LoggerFactory.getLogger("container.build"))
17-
.withAdditionalIgnoreLines(
18+
.withPostGitIgnoreLines(
1819
// Ignore files that aren't related to the built code
1920
".git/**",
2021
".config/**",
@@ -26,11 +27,11 @@ public static void main(final String[] args)
2627
"/renovate.json5",
2728
// We need to keep the pom.xml as maven can't resolve the modules otherwise
2829
"testcontainers-advanced-imagebuilder/src/**",
29-
"testcontainers-advanced-imagebuilder/test/**",
3030
"testcontainers-advanced-imagebuilder-demo/src/**"
3131
)
3232
.withDockerFilePath(Paths.get("../testcontainers-advanced-imagebuilder-demo/Dockerfile"))
33-
.withBaseDir(Paths.get("../"));
33+
.withBaseDir(Paths.get("../"))
34+
.withDockerFileLinesModifier(new DockerfileCOPYParentsEmulator());
3435

3536
final String imageName = builder.get();
3637

testcontainers-advanced-imagebuilder-dummy-app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>testcontainers-advanced-imagebuilder-dummy-app</artifactId>
9-
<version>1.2.1-SNAPSHOT</version>
9+
<version>2.0.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<organization>

testcontainers-advanced-imagebuilder/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>testcontainers-advanced-imagebuilder</artifactId>
9-
<version>1.2.1-SNAPSHOT</version>
9+
<version>2.0.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>testcontainers-advanced-imagebuilder</name>
@@ -245,7 +245,7 @@
245245
<plugin>
246246
<groupId>org.sonatype.central</groupId>
247247
<artifactId>central-publishing-maven-plugin</artifactId>
248-
<version>0.7.0</version>
248+
<version>0.8.0</version>
249249
<extensions>true</extensions>
250250
<configuration>
251251
<publishingServerId>sonatype-central-portal</publishingServerId>

0 commit comments

Comments
 (0)