Skip to content

Commit 1a54e0a

Browse files
authored
🐳 Refactor Dockerfile to decouple from Maven and enable CLI builds (#723)
* Refactor Dockerfile to decouple from Maven and enable CLI builds - Dockerfile now uses a multi-stage build to download the aas4j-model (version 1.0.4) directly from Maven Central - Removed dependency on Maven build output for external libraries - Image can now be built using only `docker build`, without requiring Maven for dependency resolution - Updated GitHub workflow to include Docker image build step * Remove unused lines from docker file
1 parent 4ab5bde commit 1a54e0a

4 files changed

Lines changed: 32 additions & 49 deletions

File tree

.github/workflows/docker-milestone-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
- name: submodel-repository
2121
path: basyx.submodelrepository/basyx.submodelrepository.component
2222
- name: submodel-service
23+
path: basyx.submodelservice/basyx.submodelservice.component
24+
- name: conceptdescription-repository
2325
path: basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component
2426
- name: aas-discovery
2527
path: basyx.aasdiscoveryservice/basyx.aasdiscoveryservice.component

.github/workflows/docker-snapshot-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
- name: submodel-repository
3737
path: basyx.submodelrepository/basyx.submodelrepository.component
3838
- name: submodel-service
39+
path: basyx.submodelservice/basyx.submodelservice.component
40+
- name: conceptdescription-repository
3941
path: basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component
4042
- name: aas-discovery
4143
path: basyx.aasdiscoveryservice/basyx.aasdiscoveryservice.component
Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
1+
# Stage 1: Download the AAS4J dependency
2+
FROM maven:3.9-eclipse-temurin-17 AS maven-downloader
3+
ARG AAS4J_VERSION=1.0.4
4+
WORKDIR /download
5+
RUN mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.6.0:get \
6+
-Dartifact=org.eclipse.digitaltwin.aas4j:aas4j-model:${AAS4J_VERSION} \
7+
&& mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.6.0:copy \
8+
-Dartifact=org.eclipse.digitaltwin.aas4j:aas4j-model:${AAS4J_VERSION} \
9+
-DoutputDirectory=/download
10+
11+
# Stage 2: Build image
112
FROM eclipse-temurin:17
2-
RUN mkdir -p /application/classes
3-
RUN chmod -R a+rwx /application/classes
4-
USER nobody
5-
WORKDIR /application
6-
ARG JAR_FILE=target/*-exec.jar
7-
COPY ${JAR_FILE} basyxExecutable.jar
8-
ARG AAS4J_VERSION=${aas4j-version}
9-
ARG AAS4J_JAR_FILE=target/libs/aas4j-model-${AAS4J_VERSION}.jar
10-
COPY ${AAS4J_JAR_FILE} libs/aas4j-model-${AAS4J_VERSION}.jar
13+
ARG AAS4J_VERSION=1.0.4
1114
ARG PORT=8081
12-
ENV SERVER_PORT=${PORT}
1315
ARG CONTEXT_PATH=/
16+
ENV SERVER_PORT=${PORT}
1417
ENV SERVER_SERVLET_CONTEXT_PATH=${CONTEXT_PATH}
18+
WORKDIR /application
19+
20+
RUN mkdir -p /application/classes /application/libs && \
21+
chmod -R a+rwx /application
22+
23+
USER nobody
24+
25+
COPY target/*-exec.jar basyxExecutable.jar
26+
COPY --from=maven-downloader /download/aas4j-model-${AAS4J_VERSION}.jar libs/
27+
1528
EXPOSE ${SERVER_PORT}
16-
HEALTHCHECK --interval=10s --timeout=3s --retries=10 --start-period=5s CMD curl --fail http://localhost:${SERVER_PORT}${SERVER_SERVLET_CONTEXT_PATH%/}/actuator/health || exit 1
17-
ENTRYPOINT ["java", "-jar", "basyxExecutable.jar"]
29+
30+
HEALTHCHECK --interval=10s --timeout=3s --retries=10 --start-period=5s \
31+
CMD curl --fail http://localhost:${SERVER_PORT}${SERVER_SERVLET_CONTEXT_PATH%/}/actuator/health || exit 1
32+
33+
ENTRYPOINT ["java", "-jar", "basyxExecutable.jar"]

basyx.submodelservice/basyx.submodelservice.component/pom.xml

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -74,49 +74,13 @@
7474

7575
<build>
7676
<plugins>
77-
<plugin>
78-
<groupId>org.apache.maven.plugins</groupId>
79-
<artifactId>maven-dependency-plugin</artifactId>
80-
<executions>
81-
<execution>
82-
<id>download-artifact</id>
83-
<goals>
84-
<goal>copy</goal>
85-
</goals>
86-
<phase>validate</phase>
87-
<configuration>
88-
<artifactItems>
89-
<artifactItem>
90-
<groupId>org.eclipse.digitaltwin.aas4j</groupId>
91-
<artifactId>aas4j-model</artifactId>
92-
<version>${aas4j-version}</version>
93-
<type>jar</type>
94-
<outputDirectory>
95-
${project.build.directory}/libs</outputDirectory>
96-
</artifactItem>
97-
</artifactItems>
98-
</configuration>
99-
</execution>
100-
</executions>
101-
</plugin>
10277
<plugin>
10378
<groupId>org.springframework.boot</groupId>
10479
<artifactId>spring-boot-maven-plugin</artifactId>
10580
<configuration>
10681
<classifier>exec</classifier>
10782
</configuration>
10883
</plugin>
109-
<plugin>
110-
<groupId>org.apache.maven.plugins</groupId>
111-
<artifactId>maven-jar-plugin</artifactId>
112-
<configuration>
113-
<archive>
114-
<manifestEntries>
115-
<Class-Path>libs/aas4j-model-${aas4j-version}.jar</Class-Path>
116-
</manifestEntries>
117-
</archive>
118-
</configuration>
119-
</plugin>
12084

12185
</plugins>
12286
</build>
@@ -133,7 +97,6 @@
13397
<plugin>
13498
<groupId>io.fabric8</groupId>
13599
<artifactId>docker-maven-plugin</artifactId>
136-
<version>0.46.0</version>
137100
<configuration>
138101
<images>
139102
<image>

0 commit comments

Comments
 (0)