Skip to content

Commit

Permalink
Merge pull request #132 from JanardhanBS-SyncByte/develop
Browse files Browse the repository at this point in the history
[MOSIP-33145] Merge to develop from develop-java21
  • Loading branch information
ckm007 committed Jun 18, 2024
2 parents 48c5dba + ac38123 commit 3788d47
Show file tree
Hide file tree
Showing 34 changed files with 2,554 additions and 1,129 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ on:
- release*
- master
- 1.*
- develop
- develop*
- MOSIP*

jobs:
build-biosdk-services:
uses: mosip/kattu/.github/workflows/maven-build.yml@master
uses: mosip/kattu/.github/workflows/maven-build.yml@master-java21
with:
SERVICE_LOCATION: ./biosdk-services
BUILD_ARTIFACT: biosdk-services
Expand All @@ -37,7 +37,7 @@ jobs:
publish_to_nexus:
if: "${{ !contains(github.ref, 'master') && github.event_name != 'pull_request' && github.event_name != 'release' && github.event_name != 'prerelease' && github.event_name != 'publish' }}"
needs: build-biosdk-services
uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master
uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master-java21
with:
SERVICE_LOCATION: ./biosdk-services
secrets:
Expand All @@ -51,7 +51,7 @@ jobs:
sonar_analysis:
needs: build-biosdk-services
if: "${{ github.event_name != 'pull_request' }}"
uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master
uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21
with:
SERVICE_LOCATION: ./biosdk-services
secrets:
Expand All @@ -72,7 +72,7 @@ jobs:
SERVICE_NAME: 'biosdk-server'
BUILD_ARTIFACT: 'biosdk-services'
fail-fast: false
uses: mosip/kattu/.github/workflows/docker-build.yml@master
uses: mosip/kattu/.github/workflows/docker-build.yml@master-java21
name: ${{ matrix.SERVICE_NAME }}
with:
SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }}
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[![Maven Package upon a push](https://github.com/mosip/biosdk-services/actions/workflows/push_trigger.yml/badge.svg?branch=develop)](https://github.com/mosip/biosdk-services/actions/workflows/push_trigger.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?branch=develop&project=mosip_biosdk-services&metric=alert_status)](https://sonarcloud.io/dashboard?branch=develop&id=mosip_biosdk-services)


[![Maven Package upon a push](https://github.com/mosip/biosdk-services/actions/workflows/push_trigger.yml/badge.svg?branch=develop-java21)](https://github.com/mosip/biosdk-services/actions/workflows/push_trigger.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?branch=develop-java21&project=mosip_biosdk-services&metric=alert_status)](https://sonarcloud.io/dashboard?branch=develop-java21&id=mosip_biosdk-services)

# Bio-SDK Service

## Overview
This is reference service and provides a mock implementation of Bio-SDK REST Service. By default loads [Mock BIO SDK](https://github.com/mosip/mosip-mock-services/tree/master/mock-sdk) internally on the startup and exposes the endpoints to perform 1:1 match, extraction as per the [IBioAPI](https://github.com/mosip/commons/blob/master/kernel/kernel-biometrics-api/src/main/java/io/mosip/kernel/biometrics/spi/IBioApi.java).
This is reference service and provides a mock implementation of Bio-SDK REST Service. By default loads [Mock BIO SDK](https://github.com/mosip/mosip-mock-services/tree/master/mock-sdk) internally on the startup and exposes the endpoints to perform 1:1 match, extraction as per the [IBioAPIV2](https://github.com/mosip/commons/blob/master/kernel/kernel-biometrics-api/src/main/java/io/mosip/kernel/biometrics/spi/IBioApiV2.java).

To know more about Biometric SDK, refer [biometric-sdk](https://docs.mosip.io/1.2.0/biometrics/biometric-sdk).

Expand Down
64 changes: 26 additions & 38 deletions biosdk-services/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
FROM openjdk:11
FROM mosipdev/openjdk-21-jre:latest

# label to be assigned along with Docker build [Mandatory]
ARG SOURCE
ARG COMMIT_HASH
ARG COMMIT_ID
ARG BUILD_TIME
LABEL source=${SOURCE}
LABEL commit_hash=${COMMIT_HASH}
LABEL commit_id=${COMMIT_ID}
LABEL build_time=${BUILD_TIME}

# can be passed during Docker build as build time environment for github branch to pickup configuration from.
ARG spring_config_label
Expand All @@ -9,33 +19,13 @@ ARG active_profile
# can be passed during Docker build as build time environment for config server URL
ARG spring_config_url

# can be passed during Docker build as build time environment for application name
ARG spring_application_name

# can be passed during Docker build as build time environment for config name
ARG spring_cloud_config_name

# can be passed during Docker build as build time environment for context path
ARG server_servlet_context

# environment variable to pass github branch to pickup configuration from, at docker runtime
ENV spring_config_label_env=${spring_config_label}

# environment variable to pass active profile such as DEV, QA etc at docker runtime
ENV active_profile_env=${active_profile}

# environment variable to pass spring configuration url, at docker runtime
ENV spring_config_url_env=${spring_config_url}

# environment variable to pass spring application name, at docker runtime
ENV spring_application_name_env=${spring_application_name}

# environment variable to pass spring config name, at docker runtime
ENV spring_cloud_config_name_env=${spring_cloud_config_name}

# environment variable to pass spring context path , at docker runtime
ENV server_servlet_context_env=${server_servlet_context}

ARG biosdk_zip_url

ENV biosdk_zip_file_path=${biosdk_zip_url}
Expand Down Expand Up @@ -65,44 +55,42 @@ ARG container_user_uid=1001
# can be passed during Docker build as build time environment for github branch to pickup configuration from.
ARG container_user_gid=1001

# install packages and create user
RUN apt-get -y update \
&& apt-get install -y unzip sudo\
&& groupadd -g ${container_user_gid} ${container_user_group} \
&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user}

# set working directory for the user
WORKDIR /home/${container_user}

ENV work_dir=/home/${container_user}

ARG loader_path=${work_dir}/additional_jars/

RUN mkdir -p ${loader_path}

ENV loader_path_env=${loader_path}

ARG logging_level_root=INFO

ENV logging_level_root_env=${logging_level_root}

ADD ./target/biosdk-services-*.jar biosdk-services.jar

ADD ./configure_biosdk.sh configure_biosdk.sh
# install packages and create user for ubunutu latest
RUN apt-get update && \
apt-get install -y --no-install-recommends sudo && \
groupadd -g ${container_user_gid} ${container_user_group} && \
useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} && \
mkdir -p /home/${container_user} ${loader_path}


RUN chmod 775 biosdk-services.jar
ADD configure_biosdk.sh /home/${container_user}/configure_biosdk.sh

RUN chmod +x configure_biosdk.sh
ADD ./target/biosdk-services-*.jar biosdk-services.jar

# change permissions of file inside working dir
RUN chown -R ${container_user}:${container_user} /home/${container_user}
RUN chmod +x /home/${container_user}/configure_biosdk.sh \
&& chmod a-w /home/${container_user}/configure_biosdk.sh \
&& chmod 775 biosdk-services.jar \
&& chown -R ${container_user}:${container_user} /home/${container_user}

# select container user for all tasks
USER ${container_user_uid}:${container_user_gid}

EXPOSE 9099

ENTRYPOINT [ "./configure_biosdk.sh" ]
ENTRYPOINT ["./configure_biosdk.sh"]

CMD echo $biosdk_bioapi_impl ; \
java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -jar biosdk-services.jar
java -Dloader.path="${loader_path_env}" -Dserver.servlet.context-path="${service_context_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" --add-modules=ALL-SYSTEM --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.stream=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.time.LocalDate=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime.date=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect.DirectMethodHandleAccessor=ALL-UNNAMED -jar biosdk-services.jar
8 changes: 4 additions & 4 deletions biosdk-services/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Bio SDK services

This service provides a mock implementation of Bio-SDK REST Service. It by default loads [Mock BIO SDK](https://github.com/mosip/mosip-mock-services/tree/master/mock-sdk) internally on the startup and exposes the endpoints to perform 1:N match, segmentation, extraction as per the [IBioAPI](https://github.com/mosip/commons/blob/master/kernel/kernel-biometrics-api/src/main/java/io/mosip/kernel/biometrics/spi/IBioApi.java). This can be configured to load a different JAR that has a different implementation of `IBioAPI`, provided its dependencies are in place.
This service provides a mock implementation of Bio-SDK REST Service. It by default loads [Mock BIO SDK](https://github.com/mosip/mosip-mock-services/tree/master/mock-sdk) internally on the startup and exposes the endpoints to perform 1:N match, segmentation, extraction as per the [IBioAPI](https://github.com/mosip/commons/blob/master/kernel/kernel-biometrics-api/src/main/java/io/mosip/kernel/biometrics/spi/IBioApiV2.java). This can be configured to load a different JAR that has a different implementation of `IBioAPIV2`, provided its dependencies are in place.

## Requirements:
* Java version = 11.X.X
* Maven version >= 3.6
* Java version = 21.X.X
* Maven version >= 3.9.6

## Run jar directly

Expand All @@ -18,7 +18,7 @@ mvn clean install
### Run jar

```text
java -Dloader.path=<biosdk jar provided by third-party vendors> -Dbiosdk_bioapi_impl=<classpath of class that implements IBioApi interface> -jar biosdk-services-<version>.jar
java -Dloader.path=<biosdk jar provided by third-party vendors> -Dbiosdk_bioapi_impl=<classpath of class that implements IBioApi interface> --add-modules=ALL-SYSTEM --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.stream=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.time.LocalDate=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime.date=ALL-UNNAMED -jar biosdk-services-<version>.jar
```

For example:
Expand Down
5 changes: 3 additions & 2 deletions biosdk-services/configure_biosdk.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash
#!/bin/sh
# Built by MOSIP team
# Script to configure the BioSDK
set -e

echo "starting downloading zip file $biosdk_zip_file_path"

wget -q --show-progress "$biosdk_zip_file_path"
wget -q "$biosdk_zip_file_path"

echo "Downloaded $biosdk_zip_file_path"

FILE_NAME=${biosdk_zip_file_path##*/}
Expand Down
Loading

0 comments on commit 3788d47

Please sign in to comment.