Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,74 @@ jobs:
--file pom.xml
--settings $GITHUB_WORKSPACE/settings.xml
install
-U
-U

docker-snapshot:
if: "github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[maven-release-plugin]')"
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 25
check-latest: true
settings-path: ${{ github.workspace }}
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-
- name: Calculate pre-release version
id: version
run: |
# Extract base version from pom.xml (remove -SNAPSHOT)
BASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//')
# Create timestamp-based pre-release version
TIMESTAMP=$(date -u +%Y%m%d%H%M%S)
PRERELEASE_VERSION="${BASE_VERSION}-dev.${TIMESTAMP}"
echo "prerelease_version=${PRERELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "Building Docker images with version: ${PRERELEASE_VERSION}"
- name: Build Services Docker Images
working-directory: ${{ github.workspace }}/services
run: >
mvn
--show-version
--batch-mode
--no-transfer-progress
--activate-profiles docker-snapshot
--file pom.xml
--settings $GITHUB_WORKSPACE/settings.xml
clean
install
spring-boot:build-image
-Ddocker.image.version=${{ steps.version.outputs.prerelease_version }}
-DskipTests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ github.actor }}
- name: Build Test Apps Docker Images
working-directory: ${{ github.workspace }}/test-apps
run: >
mvn
--show-version
--batch-mode
--no-transfer-progress
--activate-profiles docker-snapshot
--file pom.xml
--settings $GITHUB_WORKSPACE/settings.xml
clean
install
spring-boot:build-image
-Ddocker.image.version=${{ steps.version.outputs.prerelease_version }}
-DskipTests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ github.actor }}
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@
<profile>
<id>maven-release</id>
</profile>
<profile>
<id>docker-snapshot</id>
<properties>
<!-- This property will be set by the CI workflow to include git SHA in the version -->
<docker.image.version>${project.version}</docker.image.version>
</properties>
</profile>
<profile>
<id>ci</id>
<build>
Expand Down
37 changes: 37 additions & 0 deletions services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,43 @@
</plugins>
</build>
</profile>
<profile>
<id>docker-snapshot</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<docker>
<publishRegistry>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
<url>docker://ghcr.io</url>
</publishRegistry>
</docker>
<image>
<builder>docker.io/paketobuildpacks/builder-noble-java-tiny:latest</builder>
<runImage>docker.io/paketobuildpacks/run-noble-tiny:latest</runImage>
<name>ghcr.io/elasticsoftwarefoundation/${project.artifactId}:${docker.image.version}</name>
<publish>true</publish>
<env>
<BP_JVM_VERSION>${java.version}</BP_JVM_VERSION>
<BP_JVM_JLINK_ENABLED>false</BP_JVM_JLINK_ENABLED>
</env>
<buildpacks>
<buildpack>paketo-buildpacks/ca-certificates</buildpack>
<buildpack>gcr.io/paketo-buildpacks/adoptium:latest</buildpack>
<buildpack>paketo-buildpacks/syft</buildpack>
<buildpack>paketo-buildpacks/executable-jar</buildpack>
<buildpack>paketo-buildpacks/spring-boot</buildpack>
</buildpacks>
</image>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>native</id>
<build>
Expand Down
50 changes: 50 additions & 0 deletions test-apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,56 @@
</plugins>
</build>
</profile>
<profile>
<id>docker-snapshot</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<docker>
<publishRegistry>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
<url>docker://ghcr.io</url>
</publishRegistry>
</docker>
<image>
<builder>paketobuildpacks/builder-jammy-buildpackless-base:latest</builder>
<runImage>docker.io/paketobuildpacks/run-jammy-base:latest</runImage>
<name>ghcr.io/elasticsoftwarefoundation/${project.artifactId}:${docker.image.version}</name>
<publish>true</publish>
<env>
<BP_JVM_VERSION>${java.version}</BP_JVM_VERSION>
<BP_JVM_JLINK_ENABLED>false</BP_JVM_JLINK_ENABLED>
<BP_SPRING_AOT_ENABLED>true</BP_SPRING_AOT_ENABLED>
<BP_JVM_CDS_ENABLED>false</BP_JVM_CDS_ENABLED>
<JAVA_TOOL_OPTIONS>-XX:+UseZGC -XX:+ZGenerational</JAVA_TOOL_OPTIONS>
</env>
<buildpacks>
<buildpack>gcr.io/paketo-buildpacks/ca-certificates</buildpack>
<buildpack>gcr.io/paketo-buildpacks/adoptium:latest</buildpack>
<buildpack>gcr.io/paketo-buildpacks/syft</buildpack>
<buildpack>gcr.io/paketo-buildpacks/executable-jar</buildpack>
<buildpack>gcr.io/paketo-buildpacks/spring-boot</buildpack>
</buildpacks>
</image>
</configuration>
<executions>
<execution>
<goals>
<goal>process-aot</goal>
</goals>
<configuration>

</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>native</id>
<build>
Expand Down
Loading