Skip to content

Consolidate tool Dockerfiles into a single multi-stage Dockerfile#111

Merged
szschaler merged 12 commits into
mainfrom
copilot/refactor-dockerfile-for-tools
Apr 30, 2026
Merged

Consolidate tool Dockerfiles into a single multi-stage Dockerfile#111
szschaler merged 12 commits into
mainfrom
copilot/refactor-dockerfile-for-tools

Conversation

Copilot AI commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Each tool's Dockerfile independently ran a full Maven build, preventing Docker from caching shared build work across tools.

Changes

  • New root-level Dockerfile with the following stages:

    • mavenbuilder – single mvn clean install -Pall over the entire services/ directory; all tool service stages copy from this one cached layer
    • staticbuild-{emf,emfatic,ocl,conversion,xtext} – per-tool npm/webpack frontend builds
    • toolservice-{emf,emfatic,ocl,conversion,xtext} – final runtime images (nginx or tomcat) pulling from the shared Maven stage and the tool-specific static build; each stage copies only the Maven module folders required for that tool
  • Removed old per-tool Dockerfiles (static.emf/Dockerfile, static.emfatic/Dockerfile, static.ocl/Dockerfile, static.conversion/Dockerfile, xtext/Dockerfile, xtext/static.xtext/Dockerfile) — these are now superseded by the central Dockerfile

  • Updated README.md with a new "Building Tool Docker Images" section documenting how to build each tool service using --target

Usage

Target the relevant stage when building, e.g.:

docker build --target toolservice-emf      -t emf-tool      .
docker build --target toolservice-emfatic  -t emfatic-tool  .
docker build --target toolservice-ocl      -t ocl-tool      .
docker build --target toolservice-conversion -t conversion-tool .
docker build --target toolservice-xtext    -t xtext-tool    .

The central Dockerfile requires the build context to be the repository root. Updating the main docker-compose to target these stages is a follow-up in a separate repository.

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve tool Docker file performance</issue_title>
<issue_description>The docker files for the various tools (/static.xxx/Dockerfile) re-run Maven repeatedly. The way this is currently written, docker has no way to identify that parts of this build are redundant.

Instead, we should have just one staged-build Dockerfile for all tool services. This would start with a stage that builds all tools in one Maven call and then we would have separate stages for building each tool, copying the required information as and when. In the main docker-compose file, we then call the appropriate stage in this central Dockerfile instead of using a separate Dockerfile for each tool.

This way, Maven has to run once and the results can then be cached by Docker across all tools. </issue_description>

<agent_instructions>Make a first refactoring of all the relevant Dockerfiles into one central Dockerfile. Ignore the comment about the central docker-compose file, which is in a separate repository and needs a separate PR there.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Refactor tool Dockerfiles into one central Dockerfile Consolidate tool Dockerfiles into a single multi-stage Dockerfile Mar 24, 2026
Copilot AI requested a review from szschaler March 24, 2026 20:29
Comment thread Dockerfile Outdated

Copilot AI 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.

Pull request overview

This PR introduces a single root-level multi-stage Dockerfile that centralizes the Maven build for all tool services and then produces separate final images per tool by targeting different stages.

Changes:

  • Adds a root Dockerfile with a shared mavenbuilder stage that builds all tool modules with -Pall.
  • Adds per-tool frontend build stages (EMF, Emfatic, OCL, Conversion, Xtext) and per-tool final service stages.
  • Updates service stages to copy only the Maven module folders needed for each tool (mirroring the original per-tool profile module sets).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile
Comment thread Dockerfile
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile
Comment thread Dockerfile Outdated
@szschaler

szschaler commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Works in principle (tested on staging via mdenet/educationplatform-docker#83). Outstanding tasks before merge:

  • Carefully compare old dockerfiles with new dockerfile to ensure nothing was lost in the transition
    • Conversion tools
    • Emfatic
    • OCL
    • EMF
    • Xtext
  • Remove old dockerfiles
  • Consider Copilot suggestions and either move to separate issue/PR or implement directly
  • Update README file to document how to build tools

@szschaler

Copy link
Copy Markdown
Contributor

@copilot draft an update to the readme file and add it to this PR.

Copilot AI commented Mar 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot draft an update to the readme file and add it to this PR.

Done in 01cbd13. The README now has a "Building Tool Docker Images" section documenting the docker build --target <stage> commands for each tool, noting that the repository root must be the build context, and including the optional build args for the Xtext stage.

Works in principle (tested on staging via mdenet/educationplatform-docker#83). Outstanding tasks before merge:

  • Carefully compare old dockerfiles with new dockerfile to...

Done in 01cbd13:

  • Compared old Dockerfiles with the new one — all behaviour is preserved (module sets, install commands, start scripts, env vars)
  • Removed all old per-tool Dockerfiles (static.emf, static.emfatic, static.ocl, static.conversion, xtext/Dockerfile, xtext/static.xtext/Dockerfile)
  • Updated README with build instructions

The Copilot reviewer suggestions (Node EOL, npm ci, && chaining, SHASUM verification) are noted — I'll leave those for a follow-up PR as they are independent improvements.

To be considered later, whether this needs to be consistently applied across tools...
Not sure this is actually used anywhere, but at least this way it's consistent with what we do in the main repo
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@szschaler

Copy link
Copy Markdown
Contributor

While doing this, might as well update the GitHub actions to move away from Node 20 Actions, which will deprecate in June 2026.

@szschaler szschaler marked this pull request as ready for review April 2, 2026 18:10
@szschaler szschaler requested a review from Copilot April 30, 2026 16:22

Copilot AI 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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Dockerfile Outdated
Comment thread Dockerfile
Comment thread .github/workflows/ci.yml
Comment thread README.md
Comment thread xtext/docker-compose.yml
Comment thread Dockerfile
@szschaler

Copy link
Copy Markdown
Contributor

Works on staging...

@szschaler szschaler merged commit e8fe577 into main Apr 30, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Education Platform Apr 30, 2026
@szschaler szschaler deleted the copilot/refactor-dockerfile-for-tools branch April 30, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Improve tool Docker file performance

3 participants