-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into update-from-template-merged
- Loading branch information
Showing
22 changed files
with
1,206 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# 1.0.1 | ||
* Minor improvements in cleanup behavior (backported from upstream) | ||
|
||
# 1.0.0 | ||
_Initial release_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Stage 1: Build the dummy app | ||
ARG JAVA_VERSION=21 | ||
FROM eclipse-temurin:$JAVA_VERSION-jdk-alpine AS build-env | ||
|
||
RUN apk add --no-cache git bash | ||
|
||
# Create non root user | ||
ARG userName=limitedbuild | ||
ARG groupName=limitedbuild | ||
ARG userId=1000 | ||
|
||
RUN addgroup --system ${groupName} \ | ||
&& adduser --uid ${userId} --system --disabled-password --shell /bin/bash ${userName} \ | ||
&& adduser ${userName} ${groupName} | ||
|
||
# Create build dir | ||
RUN mkdir /build \ | ||
&& chown ${userName}:${groupName} /build | ||
WORKDIR /build | ||
|
||
USER ${userName} | ||
|
||
# Copying context is prepared by Testcontainers | ||
COPY --chown=${userName}:${groupName} . ./ | ||
|
||
# RUN chmod +x ./mvnw | ||
ARG mvncmd='clean package -pl "testcontainers-advanced-imagebuilder-dummy-app" -am -T2C -Dmaven.test.skip' | ||
|
||
RUN echo "Executing '$mvncmd'" | ||
RUN chmod +x ./mvnw \ | ||
&& ./mvnw -B ${mvncmd} | ||
|
||
# Stage 2: Build the executable image | ||
FROM eclipse-temurin:21-jre-alpine | ||
|
||
ARG user=dummy-app | ||
ARG group=dummy-app | ||
ARG uid=1000 | ||
ARG gid=1000 | ||
ARG APP_DIR=/opt/dummy-app | ||
|
||
# Create user + group + home | ||
RUN mkdir -p ${APP_DIR} \ | ||
&& chown ${uid}:${gid} ${APP_DIR} \ | ||
&& addgroup -g ${gid} ${group} \ | ||
&& adduser -h "$APP_DIR" -u ${uid} -G ${group} -s /bin/bash -D ${user} | ||
|
||
EXPOSE 8080 | ||
|
||
USER ${user} | ||
|
||
COPY --from=build-env --chown=${user}:${group} build/testcontainers-advanced-imagebuilder-dummy-app/target/dummy-app.jar ${APP_DIR}/dummy-app.jar | ||
|
||
CMD java ${JAVA_OPTS} -jar /opt/dummy-app/dummy-app.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
testcontainers-advanced-imagebuilder-demo/src/main/java/software/xdev/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package software.xdev; | ||
|
||
import java.nio.file.Paths; | ||
|
||
import org.slf4j.LoggerFactory; | ||
|
||
import software.xdev.testcontainers.imagebuilder.AdvancedImageFromDockerFile; | ||
|
||
|
||
public final class Application | ||
{ | ||
@SuppressWarnings("java:S106") | ||
public static void main(final String[] args) | ||
{ | ||
final AdvancedImageFromDockerFile builder = new AdvancedImageFromDockerFile("dynamically-built") | ||
.withLoggerForBuild(LoggerFactory.getLogger("container.build")) | ||
.withAdditionalIgnoreLines( | ||
// Ignore files that aren't related to the built code | ||
".git/**", | ||
".config/**", | ||
".github/**", | ||
".idea/**", | ||
".run/**", | ||
".md", | ||
".cmd", | ||
"/renovate.json5", | ||
// We need to keep the pom.xml as maven can't resolve the modules otherwise | ||
"testcontainers-advanced-imagebuilder/src/**", | ||
"testcontainers-advanced-imagebuilder/test/**", | ||
"testcontainers-advanced-imagebuilder-demo/src/**" | ||
) | ||
.withDockerFilePath(Paths.get("../testcontainers-advanced-imagebuilder-demo/Dockerfile")) | ||
.withBaseDir(Paths.get("../")); | ||
|
||
final String imageName = builder.get(); | ||
|
||
System.out.println("Successfully build " + imageName); | ||
} | ||
|
||
private Application() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a dummy application that can be started as a container |
Oops, something went wrong.