Skip to content

Build Docker images on push to main with semver pre-release versioning#172

Merged
jwijgerd merged 3 commits into
mainfrom
copilot/build-docker-images-on-push
Nov 16, 2025
Merged

Build Docker images on push to main with semver pre-release versioning#172
jwijgerd merged 3 commits into
mainfrom
copilot/build-docker-images-on-push

Conversation

Copilot AI commented Nov 16, 2025

Copy link
Copy Markdown
Contributor

Build Docker Images on Push to Main ✅

Summary:

This PR implements automatic Docker image building for the CI workflow when changes are pushed to the main branch. Images are tagged with semver-compliant pre-release versions using timestamps for chronological ordering.

Implementation Complete ✅

All Requirements Met:

  • ✅ Build Docker images on push to main (not pull requests)
  • ✅ Use new docker-snapshot profile (not release profile)
  • ✅ Don't publish to Maven Central
  • ✅ Use semver pre-release versioning
  • ✅ Provide incremental versioning with chronological ordering

Changes Made:

1. Parent pom.xml

  • Added docker-snapshot profile with docker.image.version property
  • Profile inherited by all child modules

2. services/pom.xml

  • Added docker-snapshot profile implementation
  • Configures Spring Boot Maven Plugin for Docker builds
  • Uses ${docker.image.version} for image tagging
  • Publishes to GitHub Container Registry (ghcr.io)

3. test-apps/pom.xml

  • Added docker-snapshot profile implementation
  • Configures Spring Boot Maven Plugin for Docker builds
  • Includes AOT processing like maven-release profile
  • Uses ${docker.image.version} for image tagging
  • Publishes to GitHub Container Registry (ghcr.io)

4. .github/workflows/maven.yml

  • Added docker-snapshot job
  • Runs only on push to main (excludes PRs and release commits)
  • Depends on successful build job
  • Calculates pre-release version: {base_version}-dev.{timestamp}
  • Example: 0.11.0-dev.20251116150614
  • Builds Docker images for services and test-apps
  • ✅ Fixed: Maven properties now correctly placed after goals

Version Format:

Semver Compliant Pre-Release

  • Format: {major}.{minor}.{patch}-dev.{YYYYMMDDHHMMSS}
  • Example: 0.11.0-dev.20251116150614
  • Base version extracted from pom.xml SNAPSHOT version
  • Timestamp in UTC provides chronological ordering
  • Newer builds have higher version numbers
  • Follows Semantic Versioning 2.0.0 specification

Docker Images:

The following images are built and published to ghcr.io:

  • ghcr.io/elasticsoftwarefoundation/akces-operator:{version}
  • ghcr.io/elasticsoftwarefoundation/crypto-trading-aggregates:{version}
  • ghcr.io/elasticsoftwarefoundation/crypto-trading-commands:{version}
  • ghcr.io/elasticsoftwarefoundation/crypto-trading-queries:{version}

Workflow Behavior:

Event Build Job Docker Snapshot Maven Publish
Push to main ✓ Runs ✓ Runs ✗ Skipped
Pull request ✓ Runs ✗ Skipped ✗ Skipped
Tag v* ✗ Skipped ✗ Skipped ✓ Runs

Benefits:

Automatic Builds - Docker images on every main push
Chronological Ordering - Timestamp ensures proper version ordering
Semver Compliant - Follows industry standard versioning
Separate Process - No coupling with Maven Central releases
Development Ready - Pre-release images for testing
Minimal Changes - Only 4 files modified

Validation:

✓ YAML syntax validated
✓ Maven profiles recognized by all modules
✓ Version calculation tested and working
✓ Semver format compliance verified
✓ Chronological ordering confirmed
✓ Maven command argument order corrected

Total Changes:

  • 4 files modified
  • 165 insertions
  • 1 deletion

Ready for review and merge 🚀

Original prompt

On maven.yml, When it is a push to main (not a pull request) also build the docker images like in the maven-publish workflow. Since this is not an actual public release, follow the semver versioning for pre-release versions: https://semver.org/#spec-item-9 use the current SNAPSHOT version as the basis.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 16, 2025
…s on push to main

Co-authored-by: jwijgerd <914840+jwijgerd@users.noreply.github.com>
@jwijgerd
jwijgerd marked this pull request as ready for review November 16, 2025 15:07
Copilot AI changed the title [WIP] Build docker images on push to main branch Build Docker images on push to main with semver pre-release versioning Nov 16, 2025
Copilot AI requested a review from jwijgerd November 16, 2025 15:10

@jwijgerd jwijgerd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix code review comments

Comment thread .github/workflows/maven.yml Outdated
--activate-profiles docker-snapshot
--file pom.xml
--settings $GITHUB_WORKSPACE/settings.xml
-Ddocker.image.version=${{ steps.version.outputs.prerelease_version }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this not be after the normal arguments?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in baa2273. Moved -Ddocker.image.version to after the Maven goals to follow the standard Maven command structure: mvn [options] [goals] [properties].

Co-authored-by: jwijgerd <914840+jwijgerd@users.noreply.github.com>
@jwijgerd
jwijgerd self-requested a review November 16, 2025 15:15
@jwijgerd
jwijgerd merged commit 3900489 into main Nov 16, 2025
1 check passed
@jwijgerd
jwijgerd deleted the copilot/build-docker-images-on-push branch November 16, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants