Skip to content

Commit da9a9ba

Browse files
authored
Merge pull request #317 from cloudogu/feature/remove-graalvm
removes graal native image build
2 parents 40b86bb + 38234ee commit da9a9ba

File tree

2 files changed

+25
-81
lines changed

2 files changed

+25
-81
lines changed

Dockerfile

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -120,68 +120,13 @@ RUN mv /dist/app/src /dist-dev/src && \
120120
COPY --from=maven-build /app/gitops-playground.jar /dist-dev/gitops-playground.jar
121121
# Remove compiled GOP code from jar to avoid duplicate in dev image, allowing for scripting.
122122
# Keep generated class Version, to avoid ClassNotFoundException.
123-
RUN zip -d /dist-dev/gitops-playground.jar 'com/cloudogu/gitops/*' -x com/cloudogu/gitops/cli/Version.class
123+
# RUN zip -d /dist-dev/gitops-playground.jar 'com/cloudogu/gitops/*' -x com/cloudogu/gitops/cli/Version.class
124124

125125
# Required to prevent Java exceptions resulting from AccessDeniedException by jgit when running arbitrary user
126126
RUN mkdir -p /dist/root/.config/jgit
127127
RUN touch /dist/root/.config/jgit/config
128128
RUN chmod +r /dist/root/ && chmod g+rw /dist/root/.config/jgit/
129129

130-
# This stage builds a static binary using graal VM. For details see docs/developers.md#GraalVM
131-
FROM graal AS native-image
132-
ENV MAVEN_OPTS='-Dmaven.repo.local=/mvn'
133-
RUN microdnf install gnupg
134-
135-
# Provide binaries used by apply-ng, so our runs with native-image-agent dont fail
136-
# with "java.io.IOException: Cannot run program "kubectl"..." etc.
137-
RUN microdnf install iproute
138-
139-
WORKDIR /app
140-
141-
# Copy only binaries, not jenkins plugins. Avoids having to rebuild native image only plugin changes
142-
COPY --from=downloader /dist/usr/ /usr/
143-
COPY --from=downloader /dist/app/ /app/
144-
# copy only resources that we need to compile the binary
145-
COPY --from=maven-build /app/gitops-playground.jar /app/
146-
147-
# Create Graal native image config
148-
RUN java -agentlib:native-image-agent=config-output-dir=conf/ -jar gitops-playground.jar || true
149-
# Run again with different params in order to avoid NoSuchMethodException with config file
150-
RUN printf 'registry:\n active: true\njenkins:\n active: true\ncontent:\n examples: true\napplication:\n "yes": true\nfeatures:\n argocd:\n active: true\n env:\n - name: mykey\n value: myValue\n secrets:\n vault:\n mode: "dev"\n exampleApps:\n petclinic:\n baseDomain: "base"' > config.yaml && \
151-
java -agentlib:native-image-agent=config-merge-dir=conf/ -jar gitops-playground.jar \
152-
--trace --config-file=config.yaml || true
153-
# Run again with different params in order to avoid NoSuchMethodException with output-config file
154-
RUN java -agentlib:native-image-agent=config-merge-dir=conf/ -jar gitops-playground.jar \
155-
--yes --output-config-file || true
156-
RUN native-image -Dgroovy.grape.enable=false \
157-
-H:+ReportExceptionStackTraces \
158-
-H:ConfigurationFileDirectories=conf/ \
159-
-H:IncludeResourceBundles=org.eclipse.jgit.internal.JGitText \
160-
-H:DynamicProxyConfigurationFiles=conf/proxy-config.json \
161-
-H:DynamicProxyConfigurationResources=proxy-config.json \
162-
-H:ReflectionConfigurationFiles=conf/reflect-config.json \
163-
-H:ReflectionConfigurationResources=reflect-config.json \
164-
--features=com.cloudogu.gitops.graal.groovy.GroovyApplicationRegistrationFeature,com.cloudogu.gitops.graal.groovy.GroovyDgmClassesRegistrationFeature,com.cloudogu.gitops.graal.jgit.JGitReflectionFeature,com.cloudogu.gitops.graal.okhttp.OkHttpReflectionFeature \
165-
--static \
166-
--allow-incomplete-classpath \
167-
--report-unsupported-elements-at-runtime \
168-
--diagnostics-mode \
169-
--initialize-at-run-time=org.codehaus.groovy.control.XStreamUtils,groovy.grape.GrapeIvy,org.codehaus.groovy.vmplugin.v8.Java8\$LookupHolder,org.eclipse.jgit.lib.RepositoryCache,org.eclipse.jgit.internal.storage.file.WindowCache,org.eclipse.jgit.transport.HttpAuthMethod\$Digest,org.eclipse.jgit.lib.GpgSigner,io.micronaut.context.env.exp.RandomPropertyExpressionResolver\$LazyInit \
170-
--initialize-at-build-time \
171-
--no-fallback \
172-
--libc=musl \
173-
--install-exit-handlers \
174-
-jar gitops-playground.jar \
175-
apply-ng
176-
177-
178-
179-
FROM alpine AS prod
180-
# copy groovy cli binary from native-image stage
181-
COPY --from=native-image /app/apply-ng app/apply-ng
182-
ENTRYPOINT ["/app/apply-ng"]
183-
184-
185130
FROM eclipse-temurin:${JDK_VERSION}-jre-alpine AS dev
186131

187132
# apply-ng.sh is part of the dev image and allows trying changing groovy code inside the image for debugging
@@ -204,7 +149,7 @@ ENTRYPOINT [ "java", \
204149
"/app/src/main/groovy/com/cloudogu/gitops/cli/GitopsPlaygroundCliMainScripted.groovy" ]
205150

206151
# Pick final image according to build-arg
207-
FROM ${ENV}
152+
FROM dev
208153
ENV HOME=/home \
209154
HELM_CACHE_HOME=/home/.cache/helm \
210155
HELM_CONFIG_HOME=/home/.config/helm \
@@ -248,4 +193,4 @@ LABEL org.opencontainers.image.title="gitops-playground" \
248193
org.opencontainers.image.version="${VCS_REF}" \
249194
org.opencontainers.image.created="${BUILD_DATE}" \
250195
org.opencontainers.image.ref.name="${VCS_REF}" \
251-
org.opencontainers.image.revision="${VCS_REF}"
196+
org.opencontainers.image.revision="${VCS_REF}"

Jenkinsfile

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,18 @@ node('high-cpu') {
6363
'Build images': {
6464
stage('Build images') {
6565
imageNames += createImageName(git.commitHashShort)
66-
imageNames += createImageName(git.commitHashShort) + '-dev'
6766

68-
images += buildImage(imageNames[0])
69-
images += buildImage(imageNames[1], '--build-arg ENV=dev')
67+
images += buildImage(imageNames[0], '--build-arg ENV=dev')
7068
}
7169
}
7270
)
7371
parallel(
7472
'Scan image': {
7573
stage('Scan image') {
76-
7774
scanForCriticalVulns(imageNames[0],"prod-criticals")
78-
scanForCriticalVulns(imageNames[1], "dev-criticals")
7975

8076
scanForAllVulns(imageNames[0], "prod-all")
81-
scanForAllVulns(imageNames[1], "dev-all")
77+
8278
}
8379
},
8480

@@ -95,12 +91,25 @@ node('high-cpu') {
9591
).trim()
9692

9793
docker.image(imageNames[0])
98-
.inside("-e KUBECONFIG=${env.WORKSPACE}/.kube/config " +
99-
" --network=host --entrypoint=''") {
100-
sh "/app/apply-ng --yes --trace --internal-registry-port=${registryPort} " +
101-
"--registry --jenkins --content-examples " +
102-
"--argocd --monitoring --vault=dev --ingress-nginx --mailhog --base-url=http://localhost --cert-manager"
103-
}
94+
.inside("--network=host -e KUBECONFIG=${env.WORKSPACE}/.kube/config --entrypoint=''") {
95+
sh """
96+
/app/scripts/apply-ng.sh \
97+
--yes \
98+
--trace \
99+
--argocd \
100+
--monitoring \
101+
--vault=dev \
102+
--ingress-nginx \
103+
--mailhog \
104+
--base-url=http://localhost \
105+
--cert-manager \
106+
--registry \
107+
--jenkins \
108+
--content-examples
109+
"""
110+
}
111+
112+
104113
}
105114
}
106115
)
@@ -158,12 +167,7 @@ node('high-cpu') {
158167

159168
if (git.isTag() && env.BRANCH_NAME == 'main') {
160169
// Build tags only on main to avoid human errors
161-
162-
images[1].push()
163-
images[1].push(git.tag + '-dev')
164-
images[1].push('dev')
165-
images[1].push('latest-dev')
166-
images[1].push('main-dev')
170+
167171
images[0].push()
168172
images[0].push('latest')
169173
images[0].push('main')
@@ -173,20 +177,15 @@ node('high-cpu') {
173177
currentBuild.description += "\n${imageNames[0]}"
174178

175179
} else if (env.BRANCH_NAME == 'main') {
176-
images[1].push()
177-
images[1].push('main-dev')
178180
images[0].push()
179181
images[0].push('main')
180182
currentBuild.description = "${imageNames[0]}"
181183
} else if (env.BRANCH_NAME == 'test') {
182-
images[1].push()
183-
images[1].push('test-dev')
184184
images[0].push()
185185
images[0].push('test')
186186
currentBuild.description = createImageName('test')
187187
currentBuild.description += "\n${imageNames[0]}"
188188
} else if (params.forcePushImage) {
189-
images[1].push()
190189
images[0].push()
191190
currentBuild.description = imageNames[0]
192191
} else {

0 commit comments

Comments
 (0)