-
Notifications
You must be signed in to change notification settings - Fork 7
Consolidate tool Dockerfiles into a single multi-stage Dockerfile #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,335 @@ | ||||||||||||
| # syntax=docker/dockerfile:1 | ||||||||||||
| # | ||||||||||||
| # Central multi-stage Dockerfile for all tool services. | ||||||||||||
| # | ||||||||||||
| # A single Maven build stage compiles every tool module so that Maven runs | ||||||||||||
| # only once and Docker can cache the result across all subsequent stages. | ||||||||||||
| # | ||||||||||||
| # Build a specific tool service by targeting the appropriate stage, 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 . | ||||||||||||
|
|
||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| # Stage 1 – Maven build (all modules built in a single invocation) | ||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| FROM maven:3.8.5-openjdk-17 AS mavenbuilder | ||||||||||||
|
|
||||||||||||
| COPY services /usr/src/toolfunctions | ||||||||||||
|
|
||||||||||||
| WORKDIR /usr/src/toolfunctions | ||||||||||||
|
|
||||||||||||
| RUN mvn clean install -Pall | ||||||||||||
|
|
||||||||||||
| # Get runtime dependencies used by the tool-runner stages | ||||||||||||
| RUN mvn org.apache.maven.plugins:maven-dependency-plugin:3.6.0:get \ | ||||||||||||
| -Dartifact=com.google.cloud.functions:function-maven-plugin:0.9.5 \ | ||||||||||||
| && mvn org.apache.maven.plugins:maven-dependency-plugin:3.6.0:get \ | ||||||||||||
| -Dartifact=org.apache.maven.plugins:maven-deploy-plugin:2.7 | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| # Stage 2a – Static frontend build for EMF | ||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| FROM node:19-bullseye AS staticbuild-emf | ||||||||||||
|
|
||||||||||||
| WORKDIR /usr/src/mdenet-tool | ||||||||||||
|
|
||||||||||||
| COPY static.emf/package*.json ./ | ||||||||||||
| COPY static.emf . | ||||||||||||
|
|
||||||||||||
| RUN npm install; npm run build; chmod -R 755 dist/ | ||||||||||||
|
Comment on lines
+40
to
+43
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| # Stage 2b – Static frontend build for Emfatic | ||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| FROM node:19-bullseye AS staticbuild-emfatic | ||||||||||||
|
|
||||||||||||
| WORKDIR /usr/src/mdenet-tool | ||||||||||||
|
|
||||||||||||
| COPY static.emfatic/package*.json ./ | ||||||||||||
| COPY static.emfatic . | ||||||||||||
|
|
||||||||||||
| RUN npm install; npm run build; chmod -R 755 dist/ | ||||||||||||
|
Comment on lines
+36
to
+56
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| # Stage 2c – Static frontend build for OCL | ||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| FROM node:19-bullseye AS staticbuild-ocl | ||||||||||||
|
|
||||||||||||
| WORKDIR /usr/src/mdenet-tool | ||||||||||||
|
|
||||||||||||
| COPY static.ocl/package*.json ./ | ||||||||||||
| COPY static.ocl . | ||||||||||||
|
|
||||||||||||
| RUN npm install; npm run build; chmod -R 755 dist/ | ||||||||||||
|
Comment on lines
+66
to
+69
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| # Stage 2d – Static frontend build for Conversion (Epsilon) | ||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| FROM node:19-bullseye AS staticbuild-conversion | ||||||||||||
|
|
||||||||||||
| WORKDIR /usr/src/mdenet-tool | ||||||||||||
|
|
||||||||||||
| COPY static.conversion/package*.json ./ | ||||||||||||
| COPY static.conversion . | ||||||||||||
|
|
||||||||||||
| RUN npm install; npm run build; chmod -R 755 dist/ | ||||||||||||
|
Comment on lines
+79
to
+82
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| # Stage 2e – Static frontend build for Xtext | ||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||
| FROM node:19-bullseye AS staticbuild-xtext | ||||||||||||
|
|
||||||||||||
| ARG TRUSTED_ORIGINS | ||||||||||||
|
|
||||||||||||
| RUN apt-get update && apt-get install -y --no-install-recommends zip | ||||||||||||
|
||||||||||||
| RUN apt-get update && apt-get install -y --no-install-recommends zip | |
| RUN apt-get update && apt-get install -y --no-install-recommends zip && rm -rf /var/lib/apt/lists/* |
Copilot
AI
Mar 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue here: npm install; npm run build; ... should use && to ensure failures fail the build, and prefer npm ci for lockfile installs.
Copilot
AI
Mar 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NODE_VERSION=19.9.0 is an EOL Node release. Please switch to a currently supported LTS version to reduce CVE exposure and keep npm dependency installs working over time.
Copilot
AI
Mar 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apt-get update && apt-get install ... in this stage doesn't clean /var/lib/apt/lists/*, which leaves package index files in the image and increases size. Consider adding the standard cleanup (and similarly remove any temporary artifacts created during Node installation) to keep the final image leaner.
Copilot
AI
Mar 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Xtext service installs Node by downloading a tarball via curl without any integrity verification (checksum/signature). This is a supply-chain risk; prefer installing Node from a trusted distribution mechanism (OS packages/Nodesource) or verify the download using published SHASUMS before extracting.
| && curl --output ${NODE_RELEASE}.tar.xz https://nodejs.org/download/release/v${NODE_VERSION}/${NODE_RELEASE}.tar.xz \ | |
| && curl -fsSL -o ${NODE_RELEASE}.tar.xz https://nodejs.org/download/release/v${NODE_VERSION}/${NODE_RELEASE}.tar.xz \ | |
| && curl -fsSL -o SHASUMS256.txt https://nodejs.org/download/release/v${NODE_VERSION}/SHASUMS256.txt \ | |
| && grep " ${NODE_RELEASE}.tar.xz\$" SHASUMS256.txt > SHASUMS256.txt.node \ | |
| && sha256sum -c SHASUMS256.txt.node \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Maven build stage copies the entire
services/tree before runningmvn, which means any change anywhere underservices/will invalidate the Docker cache for dependency download/build. To better leverage caching, copyservices/pom.xml(and any other Maven metadata) first and run a dependency prefetch (ormvn -Pall -DskipTests ...as appropriate), then copy the rest of the sources and run the full build.