Skip to content
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

[release-v1.15] Dockerfiles and build changes for hermetic Java builds #1287

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions data-plane/contract/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.ec4j.maven</groupId>
<artifactId>editorconfig-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

</project>
27 changes: 5 additions & 22 deletions data-plane/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
Expand Down Expand Up @@ -460,34 +464,13 @@
</from>
</configuration>
</plugin>
<plugin>
<groupId>org.ec4j.maven</groupId>
<artifactId>editorconfig-maven-plugin</artifactId>
<version>${maven.editorconfig.plugin.version}</version>
<executions>
<execution>
<id>check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>.dockerignore</exclude>
<exclude>config/***</exclude>
<exclude>.mvn/***</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<systemPropertyVariables>
<net.bytebuddy.experimental>true</net.bytebuddy.experimental>
<net.bytebuddy.experimental>true</net.bytebuddy.experimental>
</systemPropertyVariables>
<!-- This is required for the jacoco maven plugin -->
<argLine>${argLine}</argLine>
Expand Down
19 changes: 2 additions & 17 deletions openshift/ci-operator/static-images/dispatcher/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,22 @@ COPY /data-plane/receiver-loom/pom.xml receiver-loom/pom.xml
COPY /data-plane/dispatcher/pom.xml dispatcher/pom.xml
COPY /data-plane/dispatcher-loom/pom.xml dispatcher-loom/pom.xml
COPY /data-plane/contract/pom.xml contract/pom.xml
COPY /data-plane/mvnw .
COPY /data-plane/.mvn/wrapper .mvn/wrapper

# Install dependencies. Note: don't build a single submodule (receiver or dispatcher) since it just slows down
# consecutive builds.
RUN ./mvnw install -am -DskipTests -Drelease -Dlicense.skip -Deditorconfig.skip --no-transfer-progress
RUN mvn install -am -DskipTests -Drelease -Dlicense.skip -Deditorconfig.skip --no-transfer-progress

COPY /data-plane/ .

RUN ./mvnw package -pl=dispatcher-loom -Drelease -am -DskipTests -Deditorconfig.skip --no-transfer-progress
RUN mvn package -pl=dispatcher-loom -Drelease -am -DskipTests -Deditorconfig.skip --no-transfer-progress

RUN mkdir /app && cp /build/dispatcher-loom/target/dispatcher-loom-1.0-SNAPSHOT.jar /app/app.jar

# We use the generated JDK from the "builder" image, so we can just go with the ubi-minimal
FROM registry.access.redhat.com/ubi8/openjdk-21-runtime as running

EXPOSE 8080 8778 9779

USER 185

LABEL \
com.redhat.component="openshift-serverless-1-eventing-kafka-broker-dispatcher-rhel8-container" \
name="openshift-serverless-1/eventing-kafka-broker-dispatcher-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Dispatcher" \
maintainer="serverless-support@redhat.com" \
description="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Dispatcher" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Dispatcher" \
io.k8s.description="Red Hat OpenShift Serverless Eventing Kafka Broker Dispatcher" \
io.openshift.tags=Dispatcher

COPY --from=builder /app /app

ENTRYPOINT ["java", "-jar", "/app/app.jar"]
55 changes: 55 additions & 0 deletions openshift/ci-operator/static-images/dispatcher/hermetic/Dockerfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for not updating openshift/ci-operator/static-images/dispatcher/Dockerfile instead? Is it that we don't have the DEPS_IMAGE in prow-ci?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not sure if this is then detected by konflux-gen (as we need the path to this Dockerfile in the component yaml), because IIRC we get the Konflux components out of the ci-configs images section 🤔
But I probably miss something here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not sure if this is then detected by konflux-gen (as we need the path to this Dockerfile in the component yaml), because IIRC we get the Konflux components out of the ci-configs images section 🤔 But I probably miss something here

Ah found it: https://github.com/openshift-knative/hack/pull/304/files#diff-887f71c262ff6be15cc30b617c94ee85667e3ccd67aa71b7cbacd4470b031716R253.
You updated the konflux-gen for this...

Copy link
Member Author

@pierDipi pierDipi Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for not updating openshift/ci-operator/static-images/dispatcher/Dockerfile instead? Is it that we don't have the DEPS_IMAGE in prow-ci?

Yes, in prow CI there isn't a way of doing "dependent builds", so we need to have separate Dockerfiles for Konflux

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok. Thanks for clarifying

/lgtm

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright © 2018 Knative Authors (knative-dev@googlegroups.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

ARG JAVA_BUILDER=registry.access.redhat.com/ubi8/openjdk-21
ARG JAVA_RUNTIME=registry.access.redhat.com/ubi8/openjdk-21-runtime
ARG DEPS_IMAGE
ARG VERSION=""

FROM $DEPS_IMAGE AS deps

FROM $JAVA_BUILDER AS builder

USER root

WORKDIR /build

COPY --from=deps /third_party/maven/ /third_party/maven/

COPY /data-plane .

RUN mvn -Dmaven.repo.local=/third_party/maven --offline package -pl=dispatcher-loom -Drelease -am -DskipTests --no-transfer-progress

RUN mkdir /app && cp /build/dispatcher-loom/target/dispatcher-loom-1.0-SNAPSHOT.jar /app/app.jar

FROM $JAVA_RUNTIME AS running

USER 185

LABEL \
com.redhat.component="openshift-serverless-1-eventing-kafka-broker-dispatcher-rhel8-container" \
name="openshift-serverless-1/eventing-kafka-broker-dispatcher-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Dispatcher" \
maintainer="serverless-support@redhat.com" \
description="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Dispatcher" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Dispatcher" \
io.k8s.description="Red Hat OpenShift Serverless Eventing Kafka Broker Dispatcher" \
io.openshift.tags=dispatcher

COPY --from=builder /app /app

ENTRYPOINT ["java", "-jar", "/app/app.jar"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright © 2018 Knative Authors (knative-dev@googlegroups.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

ARG JAVA_BUILDER=registry.access.redhat.com/ubi8/openjdk-21

FROM $JAVA_BUILDER

USER root

WORKDIR /build

COPY /data-plane/pom.xml .
COPY /data-plane/core/pom.xml core/pom.xml
COPY /data-plane/receiver/pom.xml receiver/pom.xml
COPY /data-plane/receiver-loom/pom.xml receiver-loom/pom.xml
COPY /data-plane/dispatcher/pom.xml dispatcher/pom.xml
COPY /data-plane/dispatcher-loom/pom.xml dispatcher-loom/pom.xml
COPY /data-plane/contract/pom.xml contract/pom.xml

RUN mvn package dependency:go-offline -Drelease -DskipTests -Dmaven.repo.local=/third_party/maven
RUN find /third_party/maven/ -path "*_remote.repositories" | xargs -I{} rm {}
17 changes: 2 additions & 15 deletions openshift/ci-operator/static-images/receiver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,19 @@ COPY /data-plane/.mvn/wrapper .mvn/wrapper

# Install dependencies. Note: don't build a single submodule (receiver or dispatcher) since it just slows down
# consecutive builds.
RUN ./mvnw install -am -DskipTests -Drelease -Dlicense.skip -Deditorconfig.skip --no-transfer-progress
RUN mvn install -am -DskipTests -Drelease -Dlicense.skip -Deditorconfig.skip --no-transfer-progress

COPY /data-plane/ .

RUN ./mvnw package -pl=receiver-loom -Drelease -am -DskipTests -Deditorconfig.skip --no-transfer-progress
RUN mvn package -pl=receiver-loom -Drelease -am -DskipTests -Deditorconfig.skip --no-transfer-progress

RUN mkdir /app && cp /build/receiver-loom/target/receiver-loom-1.0-SNAPSHOT.jar /app/app.jar

# We use the generated JDK from the "builder" image, so we can just go with the ubi-minimal
FROM registry.access.redhat.com/ubi8/openjdk-21-runtime as running

EXPOSE 8080 8778 9779

USER 185

LABEL \
com.redhat.component="openshift-serverless-1-eventing-kafka-broker-receiver-rhel8-container" \
name="openshift-serverless-1/eventing-kafka-broker-receiver-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Receiver" \
maintainer="serverless-support@redhat.com" \
description="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Receiver" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Receiver" \
io.k8s.description="Red Hat OpenShift Serverless Eventing Kafka Broker Receiver" \
io.openshift.tags=Receiver

COPY --from=builder /app /app

ENTRYPOINT ["java", "-jar", "/app/app.jar"]
55 changes: 55 additions & 0 deletions openshift/ci-operator/static-images/receiver/hermetic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright © 2018 Knative Authors (knative-dev@googlegroups.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

ARG JAVA_BUILDER=registry.access.redhat.com/ubi8/openjdk-21
ARG JAVA_RUNTIME=registry.access.redhat.com/ubi8/openjdk-21-runtime
ARG DEPS_IMAGE
ARG VERSION=""

FROM $DEPS_IMAGE AS deps

FROM $JAVA_BUILDER AS builder

USER root

WORKDIR /build

COPY --from=deps /third_party/maven/ /third_party/maven/

COPY /data-plane .

RUN mvn -Dmaven.repo.local=/third_party/maven --offline package -pl=receiver-loom -Drelease -am -DskipTests --no-transfer-progress

RUN mkdir /app && cp /build/receiver-loom/target/receiver-loom-1.0-SNAPSHOT.jar /app/app.jar

FROM $JAVA_RUNTIME AS running

USER 185

LABEL \
com.redhat.component="openshift-serverless-1-eventing-kafka-broker-receiver-rhel8-container" \
name="openshift-serverless-1/eventing-kafka-broker-receiver-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Receiver" \
maintainer="serverless-support@redhat.com" \
description="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Receiver" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 Eventing Kafka Broker Receiver" \
io.k8s.description="Red Hat OpenShift Serverless Eventing Kafka Broker Receiver" \
io.openshift.tags=receiver

COPY --from=builder /app /app

ENTRYPOINT ["java", "-jar", "/app/app.jar"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright © 2018 Knative Authors (knative-dev@googlegroups.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

ARG JAVA_BUILDER=registry.access.redhat.com/ubi8/openjdk-21

FROM $JAVA_BUILDER

USER root

WORKDIR /build

COPY /data-plane/pom.xml .
COPY /data-plane/core/pom.xml core/pom.xml
COPY /data-plane/receiver/pom.xml receiver/pom.xml
COPY /data-plane/receiver-loom/pom.xml receiver-loom/pom.xml
COPY /data-plane/dispatcher/pom.xml dispatcher/pom.xml
COPY /data-plane/dispatcher-loom/pom.xml dispatcher-loom/pom.xml
COPY /data-plane/contract/pom.xml contract/pom.xml

RUN mvn package dependency:go-offline -Drelease -DskipTests -Dmaven.repo.local=/third_party/maven
RUN find /third_party/maven/ -path "*_remote.repositories" | xargs -I{} rm {}