-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfileVMBuild
293 lines (266 loc) · 14.2 KB
/
DockerfileVMBuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Use the latest Ubuntu as the base image
FROM ubuntu:latest AS maven_build
# Set the working directory
WORKDIR .
# Set environment variables to avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y sudo
# Update the package list and install necessary dependencies
RUN apt-get update && \
apt-get install -y \
curl \
tar \
git \
wget \
unzip \
software-properties-common
# Install OpenJDK 21
RUN apt-get install -y openjdk-21-jdk
# Set JAVA_HOME environment variable
ENV JAVA_HOME /usr/lib/jvm/java-21-openjdk-amd64
ENV PATH $JAVA_HOME/bin:$PATH
# Install Maven
ARG MAVEN_VERSION=3.9.9
ARG MAVEN_HOME=/opt/maven
ARG URL=https://dlcdn.apache.org/
RUN mkdir -p ${MAVEN_HOME} && \
curl -fsSL ${URL}/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz | \
tar -xzC ${MAVEN_HOME} --strip-components=1
# Set Maven environment variables
ENV MAVEN_HOME ${MAVEN_HOME}
ENV PATH $MAVEN_HOME/bin:$PATH
# Verify installations
RUN java -version && \
mvn -version
# Set MAVEN_OPTS to increase heap size
ENV MAVEN_OPTS="-Xms2048m -Xmx5g"
# Set the working directory inside the container
COPY pom.xml .
COPY adrestus-shared-resources/pom.xml ./adrestus-shared-resources/pom.xml
COPY adrestus-api/pom.xml ./adrestus-api/pom.xml
COPY adrestus-bloom-filter/pom.xml ./adrestus-bloom-filter/pom.xml
COPY adrestus-config/pom.xml ./adrestus-config/pom.xml
COPY adrestus-consensus/pom.xml ./adrestus-consensus/pom.xml
COPY adrestus-core/pom.xml ./adrestus-core/pom.xml
COPY adrestus-crypto/pom.xml ./adrestus-crypto/pom.xml
COPY adrestus-distributed-ledger/pom.xml ./adrestus-distributed-ledger/pom.xml
COPY adrestus-erasure-code/pom.xml ./adrestus-erasure-code/pom.xml
COPY adrestus-network/pom.xml ./adrestus-network/pom.xml
COPY adrestus-protocol/pom.xml ./adrestus-protocol/pom.xml
COPY adrestus-trie/pom.xml ./adrestus-trie/pom.xml
COPY adrestus-util/pom.xml ./adrestus-util/pom.xml
# Download dependencies (cached unless pom.xml changes)
RUN mvn dependency:go-offline -B
COPY adrestus-api ./adrestus-api
COPY adrestus-bloom-filter ./adrestus-bloom-filter
COPY adrestus-config ./adrestus-config
COPY adrestus-consensus ./adrestus-consensus
COPY adrestus-core ./adrestus-core
COPY adrestus-crypto ./adrestus-crypto
COPY adrestus-distributed-ledger ./adrestus-distributed-ledger
COPY adrestus-erasure-code ./adrestus-erasure-code
COPY adrestus-network ./adrestus-network
COPY adrestus-protocol ./adrestus-protocol
COPY adrestus-shared-resources/src/resources ./adrestus-shared-resources/src/resources
COPY adrestus-shared-resources/target ./adrestus-shared-resources/target
COPY adrestus-trie ./adrestus-trie
COPY adrestus-util ./adrestus-util
RUN mvn clean install -DskipTests
WORKDIR /adrestus-consensus/
RUN mvn install:install-file -Dfile=/adrestus-shared-resources/target/adrestus-shared-resources-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-shared-resources -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-distributed-ledger/target/adrestus-distributed-ledger-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-distributed-ledger -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-crypto/target/adrestus-crypto-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-crypto -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-core/target/adrestus-core-1.1-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-core -Dversion=1.1-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-config/target/adrestus-config-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-config -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-network/target/adrestus-network-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-network -Dversion=1.0-SNAPSHOT -Dpackaging=jar
WORKDIR /adrestus-core/
RUN mvn install:install-file -Dfile=/adrestus-shared-resources/target/adrestus-shared-resources-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-shared-resources -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-util/target/adrestus-util-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-util -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-trie/target/adrestus-trie-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-trie -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-distributed-ledger/target/adrestus-distributed-ledger-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-distributed-ledger -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-crypto/target/adrestus-crypto-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-crypto -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-config/target/adrestus-config-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-config -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-network/target/adrestus-network-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-network -Dversion=1.0-SNAPSHOT -Dpackaging=jar
WORKDIR /adrestus-network/
RUN mvn install:install-file -Dfile=/adrestus-shared-resources/target/adrestus-shared-resources-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-shared-resources -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-util/target/adrestus-util-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-util -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-trie/target/adrestus-trie-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-trie -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-distributed-ledger/target/adrestus-distributed-ledger-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-distributed-ledger -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-crypto/target/adrestus-crypto-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-crypto -Dversion=1.0-SNAPSHOT -Dpackaging=jar
RUN mvn install:install-file -Dfile=/adrestus-config/target/adrestus-config-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-config -Dversion=1.0-SNAPSHOT -Dpackaging=jar
## Copy only pom.xml first to allow caching of dependencies
#COPY pom.xml .
#COPY adrestus-api/pom.xml ./adrestus-api/pom.xml
#COPY adrestus-bloom-filter/pom.xml ./adrestus-bloom-filter/pom.xml
#COPY adrestus-config/pom.xml ./adrestus-config/pom.xml
#COPY adrestus-consensus/pom.xml ./adrestus-consensus/pom.xml
#COPY adrestus-core/pom.xml ./adrestus-core/pom.xml
#COPY adrestus-crypto/pom.xml ./adrestus-crypto/pom.xml
#COPY adrestus-distributed-ledger/pom.xml ./adrestus-distributed-ledger/pom.xml
#COPY adrestus-erasure-code/pom.xml ./adrestus-erasure-code/pom.xml
#COPY adrestus-network/pom.xml ./adrestus-network/pom.xml
#COPY adrestus-protocol/pom.xml ./adrestus-protocol/pom.xml
#COPY adrestus-trie/pom.xml ./adrestus-trie/pom.xml
#COPY adrestus-util/pom.xml ./adrestus-util/pom.xml
## Use BuildKit cache mount for the local .m2 directory
#RUN --mount=type=cache,target=/root/.m2 mvn dependency:go-offline
#
## Copy the actual project source
##WORKDIR ./adrestus-api
#COPY adrestus-api/src ./adrestus-api/src
#COPY adrestus-bloom-filter/src ./adrestus-bloom-filter/src
#COPY adrestus-config/src ./adrestus-config/src
#COPY adrestus-consensus/src ./adrestus-consensus/src
#COPY adrestus-core/src ./adrestus-core/src
#COPY adrestus-crypto/src ./adrestus-crypto/src
#COPY adrestus-distributed-ledger/src ./adrestus-distributed-ledger/src
#COPY adrestus-erasure-code/src ./adrestus-erasure-code/src
#COPY adrestus-network/src ./adrestus-network/src
#COPY adrestus-protocol/src ./adrestus-protocol/src
#COPY adrestus-trie/src ./adrestus-trie/src
#COPY adrestus-util/src ./adrestus-util/src
##
### Build the JAR (skipping tests to speed up dev cycle)
#RUN --mount=type=cache,target=/root/.m2 mvn clean install -DskipTests
CMD ["ls", "-la"]
# Copy the pom.xml file and download dependencies
#COPY pom.xml .
# Copy the entire project into the container
#COPY ./ .
# Download dependencies and build the project, including test classes
#RUN mvn clean install -DskipTests
# Second stage: use the Maven image again to run the tests
#FROM jelastic/maven:3.9.5-openjdk-21
#
## Set the working directory inside the container
#WORKDIR .
#
## Copy the compiled classes and test-classes from the previous stage
#COPY --from=maven_build /pom.xml /pom.xml
#COPY --from=maven_build /target /target
#
#COPY --from=maven_build /. /.
## Download dependencies (this layer will be cached if pom.xml and pom.xml.lock haven't changed)
#RUN mvn dependency:go-offline -B
##COPY --from=maven_build /adrestus-consensus/src /adrestus-consensus/src
##COPY --from=maven_build /adrestus-consensus/pom.xml /adrestus-consensus/pom.xml
##COPY --from=maven_build /adrestus-consensus/target /adrestus-consensus/target
##
##COPY --from=maven_build /adrestus-core/src /adrestus-core/src
##COPY --from=maven_build /adrestus-core/pom.xml /adrestus-core/pom.xml
##COPY --from=maven_build /adrestus-core/target /adrestus-core/target
##
##COPY --from=maven_build /adrestus-config/src /adrestus-config/src
##COPY --from=maven_build /adrestus-config/pom.xml /adrestus-config/pom.xml
##COPY --from=maven_build /adrestus-config/target /adrestus-config/target
##
##COPY --from=maven_build /adrestus-network/src /adrestus-network/src
##COPY --from=maven_build /adrestus-network/pom.xml /adrestus-network/pom.xml
##COPY --from=maven_build /adrestus-network/target /adrestus-network/target
#
#WORKDIR /adrestus-consensus/
#RUN mvn install:install-file -Dfile=/adrestus-core/target/adrestus-core-1.1-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-core -Dversion=1.1-SNAPSHOT -Dpackaging=jar
#RUN mvn install:install-file -Dfile=/adrestus-config/target/adrestus-config-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-config -Dversion=1.0-SNAPSHOT -Dpackaging=jar
#RUN mvn install:install-file -Dfile=/adrestus-network/target/adrestus-network-1.0-SNAPSHOT-jar-with-dependencies.jar -DgroupId=io.Adrestus.v1 -DartifactId=adrestus-network -Dversion=1.0-SNAPSHOT -Dpackaging=jar
## Run the tests
##RUN mvn test -Dtest=ConsensusVRFTest2
## Default command
##CMD ["ls", "-la"]
#CMD ["mvn", "test", "-Dtest=ConsensusVRFTest2"]
#FROM jelastic/maven:3.9.5-openjdk-21 AS maven_build
## Set the working directory inside the container
#WORKDIR .
#
#COPY ./ .
## Download dependencies (this layer will be cached if pom.xml and pom.xml.lock haven't changed)
#RUN mvn dependency:go-offline -B
##RUN mvn clean install -Dmaven.test.skip -Dmaven.main.skip -Dspring-boot.repackage.skip
##RUN cd module3 && mvn clean package shade:shade-Dmaven.test.skip -Dmaven.main.skip -Dspring-boot.repackage.skip
##copy source
#COPY adrestus-config/src /adrestus-config/src
#COPY adrestus-crypto/src /adrestus-crypto/src
#COPY adrestus-util/src /adrestus-utils/src
#COPY adrestus-distributed-ledger/src /adrestus-distributed-ledger/src
#COPY adrestus-trie/src /adrestus-trie/src
#COPY adrestus-bloom-filter/src /adrestus-bloom-filter
#COPY adrestus-erasure-code/src /adrestus-erasure-code/src
#COPY adrestus-network/src /adrestus-network/src
#COPY adrestus-core/src /adrestus-core/src
#COPY adrestus-consensus/src /adrestus-consensus/src
#COPY adrestus-protocol/src /adrestus-protocol/src
#COPY adrestus-api/src /adrestus-api/src
## build the app (no dependency download here)
#RUN mvn clean install -Dmaven.test.skip
#
#
### Second stage: use the Maven image again to run the tests
##FROM jelastic/maven:3.9.5-openjdk-21
##
### Set the working directory inside the container
##WORKDIR .
##
##ARG DOCKER_TARGET=/adrestus-consensus/target/
##COPY --from=maven_build ${DOCKER_TARGET} /adrestus-consensus/target
### Copy the compiled test-classes from the previous stage
###COPY --from=maven_build /target/test-classes /app/target/test-classes
###COPY --from=maven_build /target/classes /app/target/classes
###COPY --from=maven_build /target/dependency /app/target/dependency
###COPY --from=maven_build /pom.xml /app/pom.xml
###COPY --from=maven_build /.mvn /app/.mvn
##
#RUN mvn test -Dtest=ConsensusVRFTest2
#WORKDIR ./adrestus-consensus/target/test-classes
##RUN cd /adrestus-consensus/target && ls
### Default command
#CMD ["ls", "-la"]
## Run the specific test
#ENTRYPOINT ["mvn", "test", "-Dtest=ConsensusVRFTest2"]
## Use the latest Ubuntu as the base image
#FROM ubuntu:latest
## Set the working directory
#WORKDIR /app
## Set environment variables to avoid interactive prompts during package installation
#ENV DEBIAN_FRONTEND=noninteractive
#RUN apt-get update \
# && apt-get install -y sudo
#
## Update the package list and install necessary dependencies
#RUN apt-get update && \
# apt-get install -y \
# curl \
# tar \
# git \
# wget \
# unzip \
# software-properties-common
#
## Install OpenJDK 21
#RUN apt-get install -y openjdk-21-jdk
#
## Set JAVA_HOME environment variable
#ENV JAVA_HOME /usr/lib/jvm/java-21-openjdk-amd64
#ENV PATH $JAVA_HOME/bin:$PATH
#
## Install Maven
#ARG MAVEN_VERSION=3.9.9
#ARG MAVEN_HOME=/opt/maven
#ARG URL=https://dlcdn.apache.org/
#
#RUN mkdir -p ${MAVEN_HOME} && \
# curl -fsSL ${URL}/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz | \
# tar -xzC ${MAVEN_HOME} --strip-components=1
#
## Set Maven environment variables
#ENV MAVEN_HOME ${MAVEN_HOME}
#ENV PATH $MAVEN_HOME/bin:$PATH
#
## Verify installations
#RUN java -version && \
# mvn -version
#
#COPY ./ .
#RUN mvn clean package -Dmaven.test.skip=true
#
## Default command
#CMD ["ls", "-la"]