Skip to content
Snippets Groups Projects
Commit 154cc4eb authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Update to Quarkus 2.1.0 from Quarkus 0.28

parent cb67377e
No related branches found
No related tags found
2 merge requests!21Upgrade to Quarkus 2.6.3, use of common lib,!20Update to Quarkus 2.1.0 from Quarkus 0.28
Pipeline #1207 failed
Showing
with 151 additions and 291 deletions
*
!target/*-runner
!target/*-runner.jar
!target/lib/*
!bin/
!maxmind/
!reflection-config.json
......@@ -55,4 +55,5 @@ pom.xml.versionsBackup
release.properties
# MaxMind data store
maxmind/
data/
Makefile 0 → 100644
clean:;
rm -rf ./maxmind
mvn clean
install: clean;
sh ./bin/maxmind.sh maxmind/
package: install;
mvn package
docker build -f src/main/docker/Dockerfile.jvm --no-cache -t eclipsefdn/geoip-local:latest .
dirty-package:;
mvn package
docker build -f src/main/docker/Dockerfile.jvm --no-cache -t eclipsefdn/geoip-local:latest .
package-native: install;
mvn package -Pnative -Dnative-image.docker-build=true
docker build -f src/main/docker/Dockerfile.native --no-cache -t eclipsefdn/geoip-local-native:latest .
dirty-package-native:;
mvn package -Pnative -Dnative-image.docker-build=true
docker build -f src/main/docker/Dockerfile.native --no-cache -t eclipsefdn/geoip-local-native:latest .
headless-docker: package;
docker run -i --rm -p 8080:8080 eclipsefdn/geoip-local:latest
headless-docker-native: package-native;
docker run -i --rm -p 8080:8080 eclipsefdn/geoip-local-native:latest
\ No newline at end of file
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipsefoundation</groupId>
<artifactId>geoip-client</artifactId>
......@@ -10,25 +7,21 @@
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.parameters>true</maven.compiler.parameters>
<surefire-plugin.version>2.22.0</surefire-plugin.version>
<quarkus.version>0.28.0</quarkus.version>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>2.1.0.Final</quarkus.platform.version>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.source>11</maven.compiler.source>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.target>1.8</maven.compiler.target>
<sonar.sources>src/main</sonar.sources>
<sonar.tests>src/test</sonar.tests>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPaths>${project.build.directory}/jacoco-report</sonar.jacoco.reportPaths>
<sonar.junit.reportPath>${project.build.directory}/surefire-reports</sonar.junit.reportPath>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom</artifactId>
<version>${quarkus.version}</version>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
......@@ -49,10 +42,6 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
......@@ -61,18 +50,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mariadb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal</artifactId>
</dependency>
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>2.12.0</version>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
......@@ -82,98 +63,62 @@
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.0</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Required for opencsv -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<groupId>org.jboss.logging</groupId>
<artifactId>commons-logging-jboss-logging</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemProperties>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<configuration>
<destFile>${sonar.jacoco.reportPaths}</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<outputDirectory>${sonar.jacoco.reportPaths}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<properties>
<quarkus.native.additional-build-args>-H:IncludeResourceBundles=opencsv,</quarkus.native.additional-build-args>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
......@@ -183,9 +128,11 @@
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
......@@ -193,20 +140,5 @@
</plugins>
</build>
</profile>
<profile>
<id>sonar-dev</id>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
</plugin>
</plugins>
</build>
<properties>
<sonar.host.url>https://sonarqube.dev.docker</sonar.host.url>
</properties>
</profile>
</profiles>
</project>
</project>
\ No newline at end of file
......@@ -14,31 +14,61 @@
# docker run -i --rm -p 8080:8080 -v <fullpath to dir>/secrets:/run/secrets quarkus/geoip-client-jvm
#
###
FROM fabric8/java-alpine-openjdk8-jre
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the container image run:
#
# ./mvnw package
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/getting-started-jvm .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/getting-started-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 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/getting-started-jvm
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
WORKDIR /deployments/scripts
ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager \
-Xmx512m \
-Declipse.maxmind.root=/maxmind"
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=1001 target/quarkus-app/*.jar /deployments/
COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
# CUSTOM - added to pull in maxmind
COPY maxmind/ /maxmind/
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 \
-Djava.util.logging.manager=org.jboss.logmanager.LogManager \
-Xmx512m \
-Declipse.subnet.ipv4.path=/maxmind/db/GeoLite2-Country-Blocks-IPv4.csv \
-Declipse.subnet.ipv6.path=/maxmind/db/GeoLite2-Country-Blocks-IPv6.csv \
-Declipse.subnet.countries.path=/maxmind/db/GeoLite2-Country-Locations-en.csv \
-Dmaxmind.database.root=/maxmind/bin \
-Dmaxmind.database.country.file=GeoLite2-Country.mmdb \
-Dmaxmind.database.city.file=GeoLite2-City.mmdb"
ENV AB_ENABLED=jmx_exporter
COPY target/lib/* /deployments/lib/
COPY target/*-runner.jar /deployments/app.jar
EXPOSE 8080
# run with user 1001 and be prepared for be running in OpenShift too
RUN adduser -G root --no-create-home --disabled-password 1001 \
&& chown -R 1001 /deployments \
&& chmod -R "g+rwX" /deployments \
&& chown -R 1001:root /deployments
USER 1001
ENTRYPOINT [ "/deployments/run-java.sh" ]
ENTRYPOINT [ "/deployments/run-java.sh" ]
\ No newline at end of file
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
#
# Before building the docker image run:
# Before building the container image run:
#
# mvn package -Pnative -Dnative-image.docker-build=true
# ./mvnw package -Pnative
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.native -t quarkus/geoip-client .
# docker build -f src/main/docker/Dockerfile.native -t quarkus/getting-started .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/geoip-client
# docker run -i --rm -p 8080:8080 quarkus/getting-started
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal
# we need the following commands to run script
RUN microdnf install wget unzip tar findutils gzip
WORKDIR /tmp/
COPY bin/maxmind.sh /tmp
RUN chmod +x ./maxmind.sh
RUN ./maxmind.sh /tmp
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
WORKDIR /work/
COPY target/*-runner /work/application
RUN chmod 775 /work
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application
COPY --chown=1001:root maxmind/ /maxmind/
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
\ No newline at end of file
USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Declipse.maxmind.root=/maxmind"]
\ No newline at end of file
package org.eclipsefoundation.geoip.client.config;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.Metadata;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection(targets = {Metadata.class, MaxMindDbConstructor.class})
public class MaxmindReflectionRegistrationConfig {
}
/* Copyright (c) 2019 Eclipse Foundation and others.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License 2.0
* which is available at http://www.eclipse.org/legal/epl-v20.html,
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipsefoundation.geoip.client.model;
import java.sql.JDBCType;
import io.quarkus.runtime.annotations.RegisterForReflection;
/**
* @author Martin Lowe
*
*/
@RegisterForReflection
public class ParameterizedSQLStatement {
private String sql;
private Object[] params;
private JDBCType[] types;
/**
* Builds a loaded parameterized statement to be used in querying dataset.
*/
public ParameterizedSQLStatement(String sql, Object[] params, JDBCType[] types) {
this.sql = sql;
this.params = params;
this.types = types;
}
/**
* @return the sql
*/
public String getSql() {
return sql;
}
/**
* @param sql the sql to set
*/
public void setSql(String sql) {
this.sql = sql;
}
/**
* @return the params
*/
public Object[] getParams() {
return params;
}
/**
* @param params the params to set
*/
public void setParams(Object[] params) {
this.params = params;
}
/**
* @return the types
*/
public JDBCType[] getTypes() {
return types;
}
/**
* @param types the types to set
*/
public void setTypes(JDBCType[] types) {
this.types = types;
}
}
......@@ -13,18 +13,16 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import com.maxmind.geoip2.record.City;
import org.eclipsefoundation.geoip.client.helper.InetAddressHelper;
import org.eclipsefoundation.geoip.client.model.Error;
import org.eclipsefoundation.geoip.client.service.GeoIPService;
import com.maxmind.geoip2.record.City;
/**
* @author martin
*
......@@ -35,8 +33,6 @@ public class CityResource {
@Inject
GeoIPService geoIp;
@Context
UriInfo uriInfo;
@GET
@Path("/{ipAddr}")
......
......@@ -13,18 +13,16 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import com.maxmind.geoip2.record.Country;
import org.eclipsefoundation.geoip.client.helper.InetAddressHelper;
import org.eclipsefoundation.geoip.client.model.Error;
import org.eclipsefoundation.geoip.client.service.GeoIPService;
import com.maxmind.geoip2.record.Country;
/**
* @author martin
*
......@@ -35,8 +33,6 @@ public class CountryResource {
@Inject
GeoIPService geoIp;
@Context
UriInfo uriInfo;
@GET
@Path("/{ipAddr}")
......
......@@ -11,10 +11,8 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.eclipsefoundation.geoip.client.model.IPVersion;
import org.eclipsefoundation.geoip.client.service.NetworkService;
......@@ -32,9 +30,6 @@ public class SubnetResource {
@Inject
NetworkService networks;
@Context
UriInfo uriInfo;
@GET
@Path("/{ipv: (ipv[46])}/{isoLocale: ([a-zA-Z]{2})}")
public Response get(@PathParam("isoLocale") String isoLocale, @PathParam("ipv") String ipVersion) {
......
......@@ -19,13 +19,15 @@ import java.util.Objects;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import com.opencsv.bean.CsvToBeanBuilder;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipsefoundation.geoip.client.model.Country;
import org.eclipsefoundation.geoip.client.model.IPVersion;
import org.eclipsefoundation.geoip.client.model.SubnetRange;
import org.eclipsefoundation.geoip.client.service.NetworkService;
import com.opencsv.bean.CsvToBeanBuilder;
import io.quarkus.runtime.Startup;
/**
* Loads Network subnet information via CSV files on the system.
......@@ -33,6 +35,7 @@ import com.opencsv.bean.CsvToBeanBuilder;
* @author Martin Lowe
*
*/
@Startup
@ApplicationScoped
public class CSVNetworkService implements NetworkService {
......
......@@ -19,6 +19,8 @@ import org.eclipsefoundation.geoip.client.service.GeoIPService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.quarkus.runtime.Startup;
import com.maxmind.geoip2.DatabaseReader;
import com.maxmind.geoip2.exception.GeoIp2Exception;
import com.maxmind.geoip2.model.CityResponse;
......@@ -33,6 +35,7 @@ import com.maxmind.geoip2.record.Country;
*
* @author Martin Lowe
*/
@Startup
@ApplicationScoped
public class MaxMindGeoIPService implements GeoIPService {
private static final Logger LOGGER = LoggerFactory.getLogger(MaxMindGeoIPService.class);
......
......@@ -2,10 +2,14 @@
quarkus.http.port=8080
quarkus.http.root-path=/geoip
eclipse.subnet.ipv4.path=/tmp/maxmind/db/GeoLite2-Country-Blocks-IPv4.csv
eclipse.subnet.ipv6.path=/tmp/maxmind/db/GeoLite2-Country-Blocks-IPv6.csv
eclipse.subnet.countries.path=/tmp/maxmind/db/GeoLite2-Country-Locations-en.csv
maxmind.database.root=/tmp/maxmind/bin
eclipse.maxmind.root=/tmp/maxmind
eclipse.subnet.ipv4.path=${eclipse.maxmind.root}/db/GeoLite2-Country-Blocks-IPv4.csv
eclipse.subnet.ipv6.path=${eclipse.maxmind.root}/db/GeoLite2-Country-Blocks-IPv6.csv
eclipse.subnet.countries.path=${eclipse.maxmind.root}/db/GeoLite2-Country-Locations-en.csv
maxmind.database.root=${eclipse.maxmind.root}/bin
maxmind.database.country.file=GeoLite2-Country.mmdb
maxmind.database.city.file=GeoLite2-City.mmdb
%dev.quarkus.http.port=8090
\ No newline at end of file
[
{
"name" : "org.eclipsefoundation.geoip.client.model.Country",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "org.eclipsefoundation.geoip.client.model.SubnetRange",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "com.maxmind.geoip2.model.CityResponse",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "com.maxmind.geoip2.model.CountryResponse",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
},
{
"name" : "org.apache.commons.logging.impl.LogFactoryImpl",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredFields" : true,
"allPublicFields" : true
}
]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment