Skip to content

Commit

Permalink
chore(deps): move to jvm build (#303)
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
  • Loading branch information
ruromero authored Mar 11, 2024
1 parent 6685d0f commit 45f95c7
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 68 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- name: Install commitlint
run: |
npm install conventional-changelog-conventionalcommits
Expand All @@ -41,11 +41,11 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'maven'
- name: Run integration tests
run: |
./mvnw -B verify -Pnative
./mvnw -B verify
env:
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 3 additions & 5 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ env:
IMAGE_REGISTRY_USER: ${{ secrets.IMAGE_REGISTRY_USER }}
IMAGE_REGISTRY_PASSWORD: ${{ secrets.IMAGE_REGISTRY_PASSWORD }}
# 🖊️ EDIT to change Dockerfile.
DOCKERFILE_PATH: ./src/main/docker/Dockerfile.native-micro
DOCKERFILE_PATH: ./src/main/docker/Dockerfile.jvm.staged

on:
push:
branches:
- main
- stable
tags:
- '*'
workflow_dispatch:
Expand Down Expand Up @@ -88,7 +87,6 @@ jobs:
branch=${GITHUB_REF_NAME}
case ${branch} in
'main') tag='latest' ;;
'stable') tag='alpha' ;;
*) tag=${branch} ;;
esac
echo "tag=${tag}" >> $GITHUB_OUTPUT
Expand All @@ -98,12 +96,12 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'maven'

- name: Build Package with Maven
run: |
./mvnw -B verify -Pnative
./mvnw -B verify
env:
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .tekton/exhort-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ metadata:
spec:
params:
- name: dockerfile
value: src/main/docker/Dockerfile.multi-stage
value: src/main/docker/Dockerfile.jvm.staged
- name: git-url
value: '{{repo_url}}'
- name: image-expires-after
Expand Down
2 changes: 1 addition & 1 deletion .tekton/exhort-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ metadata:
spec:
params:
- name: dockerfile
value: src/main/docker/Dockerfile.multi-stage
value: src/main/docker/Dockerfile.jvm.staged
- name: git-url
value: '{{repo_url}}'
- name: output-image
Expand Down
2 changes: 1 addition & 1 deletion deploy/exhort.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
protocol: TCP
resources:
limits:
memory: "128Mi"
memory: "512Mi"
cpu: "500m"
env:
- name: API_SNYK_TOKEN
Expand Down
4 changes: 2 additions & 2 deletions deploy/openshift/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ parameters:
description: The maximum amount of CPU the container can use.
displayName: Memory Limit
required: true
value: 500m
value: 1024Mi
- name: MEMORY_REQUEST
description: The minimum amount of memory required by a container
displayName: Memory Limit
Expand All @@ -189,7 +189,7 @@ parameters:
description: The maximum amount of memory the container can use.
displayName: Memory Limit
required: true
value: 1024Mi
value: 5120Mi
- name: ENV_NAME
value: stage
displayName: Environment (default -- stage)
Expand Down
22 changes: 13 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<!-- Build properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.release>21</maven.compiler.release>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</maven.build.timestamp.format>
<timestamp>${maven.build.timestamp}</timestamp>
<skipITs>true</skipITs>
Expand All @@ -48,12 +48,12 @@
<deploy-plugin.version>3.1.1</deploy-plugin.version>

<!-- Dependencies -->
<exhort-api.version>1.0.5-SNAPSHOT</exhort-api.version>
<exhort-api.version>1.0.5</exhort-api.version>
<sentry.version>1.7.27</sentry.version>
<cyclonedx.version>8.0.3</cyclonedx.version>
<spdx.version>1.1.7</spdx.version>
<htmlunit.version>2.70.0</htmlunit.version>
<wiremock.version>3.3.1</wiremock.version>
<wiremock.version>3.4.2</wiremock.version>

<!-- Node and Yarn -->
<node.version>v20.9.0</node.version>
Expand Down Expand Up @@ -141,6 +141,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logmanager</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
Expand Down Expand Up @@ -182,6 +186,12 @@
<groupId>org.spdx</groupId>
<artifactId>spdx-jackson-store</artifactId>
<version>${spdx.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
Expand All @@ -197,12 +207,6 @@
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@
# accessed directly. (example: "foo.example.com,bar.example.com")
#
###
FROM registry.access.redhat.com/ubi8/openjdk-17:1.16
FROM registry.redhat.io/ubi9/openjdk-21:1.18

ENV LANGUAGE='en_US:en'


# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
Expand All @@ -91,3 +90,4 @@ USER 185
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
59 changes: 59 additions & 0 deletions src/main/docker/Dockerfile.jvm.staged
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm.staged -t quarkus/code-with-quarkus-jvm .
#
# Then run the container using:
#
# docker run -i --rm -p 8081:8081 quarkus/code-with-quarkus-jvm
#
# If you want to include the debug port into your docker image
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
#
# Then run the container using :
#
# docker run -i --rm -p 8080:8080 -p 9000:9000 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/code-with-quarkus-jvm
#
###
FROM registry.redhat.io/ubi9/openjdk-21:1.18

USER root
WORKDIR /build

## Maven Settings with the auth token for Github Maven Repository
COPY settings.xml settings.xml
COPY pom.xml .
COPY ui ui

RUN mvn -B --settings settings.xml org.apache.maven.plugins:maven-dependency-plugin:3.6.1:go-offline

COPY src src

RUN mvn verify -B

RUN grep version /build/target/maven-archiver/pom.properties | cut -d '=' -f2 >.env-version
RUN grep artifactId /build/target/maven-archiver/pom.properties | cut -d '=' -f2 >.env-id

# if this is an uber jar create a structure that looks the same as fast-jar with empty directories
# this allows for the same dockerfile to be used with both
RUN if [ ! -d /build/target/quarkus-app ] ; then mkdir -p /build/target/quarkus-app/lib; \
mkdir -p /build/target/quarkus-app/app; \
mkdir -p /build/target/quarkus-app/quarkus; \
mv /build/target/$(cat .env-id)-$(cat .env-version)*.jar /build/target/quarkus-app/ ; \
fi

FROM registry.redhat.io/ubi9/openjdk-21-runtime:1.18
# Configure the JAVA_OPTS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --from=0 --chown=1001 /build/target/quarkus-app/lib/ /deployments/lib/
COPY --from=0 --chown=1001 /build/target/quarkus-app/*.jar /deployments/export-run-artifact.jar
COPY --from=0 --chown=1001 /build/target/quarkus-app/app/ /deployments/app/
COPY --from=0 --chown=1001 /build/target/quarkus-app/quarkus/ /deployments/quarkus/

EXPOSE 8080
EXPOSE 9000

ENTRYPOINT ["/opt/jboss/container/java/run/run-java.sh"]
4 changes: 2 additions & 2 deletions src/main/docker/Dockerfile.multi-stage
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ COPY --chown=quarkus:quarkus settings.xml /code/settings.xml

USER quarkus
WORKDIR /code
RUN ./mvnw -B --settings /code/settings.xml org.apache.maven.plugins:maven-dependency-plugin:3.6.1:go-offline
RUN ./mvnw -B -Pnative --settings /code/settings.xml org.apache.maven.plugins:maven-dependency-plugin:3.6.1:go-offline
COPY --chown=quarkus:quarkus src /code/src
RUN ./mvnw verify -B -Pnative -Dmaven.test.skip=true -Dquarkus.native.native-image-xmx=8g
RUN ./mvnw verify -B -Dmaven.test.skip=true -Dquarkus.native.native-image-xmx=8g

## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
import org.apache.camel.Message;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.jboss.logging.Logger;

import com.github.packageurl.PackageURL;
import com.redhat.exhort.analytics.segment.Context;
Expand All @@ -58,7 +57,7 @@
@RegisterForReflection
public class AnalyticsService {

private static final Logger LOGGER = LoggerFactory.getLogger(AnalyticsService.class);
private static final Logger LOGGER = Logger.getLogger(AnalyticsService.class);

private static final String ANONYMOUS_ID = "telemetry-anonymous-id";
private static final String ANALYSIS_EVENT = "rhda.exhort.analysis";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@

import org.cyclonedx.model.Bom;
import org.cyclonedx.model.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.jboss.logging.Logger;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.redhat.exhort.api.PackageRef;
Expand All @@ -48,7 +47,7 @@
public class CycloneDxParser extends SbomParser {

private static final ObjectMapper mapper = ObjectMapperProducer.newInstance();
private static final Logger LOGGER = LoggerFactory.getLogger(CycloneDxParser.class);
private static final Logger LOGGER = Logger.getLogger(CycloneDxParser.class);

@Override
protected DependencyTree buildTree(InputStream input) {
Expand Down Expand Up @@ -143,7 +142,7 @@ private Map<PackageRef, DirectDependency> buildUnknownDependencies(
.forEach(
v -> {
if (deps.containsKey(v)) {
LOGGER.debug("Ignore duplicate key {}", v);
LOGGER.debugf("Ignore duplicate key %s", v);
}
deps.put(v, DirectDependency.builder().ref(v).build());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.jboss.logging.Logger;
import org.spdx.jacksonstore.MultiFormatStore;
import org.spdx.jacksonstore.MultiFormatStore.Format;
import org.spdx.library.InvalidSPDXAnalysisException;
Expand All @@ -47,7 +46,7 @@

public class SpdxParser extends SbomParser {

private static final Logger LOGGER = LoggerFactory.getLogger(SpdxParser.class);
private static final Logger LOGGER = Logger.getLogger(SpdxParser.class);

@Override
protected DependencyTree buildTree(InputStream input) {
Expand All @@ -58,7 +57,7 @@ protected DependencyTree buildTree(InputStream input) {
var tree = new DependencyTree(deps);
return tree;
} catch (SpdxValidationException e) {
LOGGER.info("Invalid SPDX SBOM received", e.getMessage());
LOGGER.info("Invalid SPDX SBOM received", e);
throw new ClientErrorException(e.getMessage(), Response.Status.BAD_REQUEST);
} catch (SpdxProcessingException | InvalidSPDXAnalysisException | IOException e) {
LOGGER.warn("Unable to parse the SPDX SBOM file", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
import org.apache.camel.ExchangeProperty;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.http.base.HttpOperationFailedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.jboss.logging.Logger;

import com.redhat.exhort.api.PackageRef;
import com.redhat.exhort.api.v4.DependencyReport;
Expand Down Expand Up @@ -70,7 +69,7 @@ public abstract class ProviderResponseHandler {

public static final String AFFECTED_STATUS = "Affected";

private static final Logger LOGGER = LoggerFactory.getLogger(ProviderResponseHandler.class);
private static final Logger LOGGER = Logger.getLogger(ProviderResponseHandler.class);

@Inject MonitoringProcessor monitoringProcessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@

import org.apache.camel.Body;
import org.apache.camel.ExchangeProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.jboss.logging.Logger;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -53,7 +52,7 @@
@RegisterForReflection
public class OssIndexResponseHandler extends ProviderResponseHandler {

private static final Logger LOGGER = LoggerFactory.getLogger(OssIndexRequestBuilder.class);
private static final Logger LOGGER = Logger.getLogger(OssIndexRequestBuilder.class);

@Inject ObjectMapper mapper;

Expand All @@ -72,7 +71,9 @@ private Map<String, List<Issue>> getIssues(ArrayNode response, DependencyTree tr
tree.getAll().stream()
.collect(
Collectors.toMap(
d -> new PackageRef(d.toString()).purl().getCoordinates(), d -> d));
d -> new PackageRef(d.toString()).purl().getCoordinates(),
d -> d,
(a, b) -> a));
response.forEach(
n -> {
var pkgRef = n.get("coordinates").asText();
Expand Down
Loading

0 comments on commit 45f95c7

Please sign in to comment.