From 4414da2d66f08ef1dd156bfddd13d09b1fef4496 Mon Sep 17 00:00:00 2001 From: Challarao Date: Wed, 5 Jun 2024 13:54:46 +0530 Subject: [PATCH] [INJICERT-212] make download plugins from artifactory in to default implementation Signed-off-by: Challarao --- README.md | 11 +++++-- certify-service/Dockerfile | 14 ++++++-- certify-service/configure_start.sh | 32 +++++++++++++++++++ .../docker-compose-certify/docker-compose.yml | 9 +++--- ...fy with Sunbird RC.postman_collection.json | 2 +- 5 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 certify-service/configure_start.sh diff --git a/README.md b/README.md index 090adf6f..f28692b4 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Execute installation script 1. Clone the repository and navigate to its directory: ```bash - cd inji-certify + cd inji-certify/docker-compose ./install.sh ``` @@ -47,10 +47,15 @@ Execute installation script * take note of `$.schema[0].author` and `$.schema[0].id` from the create credential schema request 6. Create a folder with name loader_path [here](docker-compose/docker-compose-certify). 7. Add the jar file of Digital Credential Stack(DCS) plugin implementations for eSignet and certify: - * For eSignet create a folder with name esignet inside loader_path folder created in the above step and add the jar files inside the folder. + * For eSignet: + * create a folder with name esignet inside loader_path folder created in the above step and add the jar files inside the folder. * JAR file for sunbird can be downloaded [here](https://mvnrepository.com/artifact/io.mosip.esignet.sunbirdrc/sunbird-rc-esignet-integration-impl). * JAR file for mock identity can be downloaded [here](https://repo1.maven.org/maven2/io/mosip/esignet/mock/mock-esignet-integration-impl/0.9.2/mock-esignet-integration-impl-0.9.2.jar) - * For certify create a folder with name certify inside loader_path folder created in the above step and add the jar file inside the folder. The JAR can be built [from source](https://github.com/mosip/digital-credential-plugins/tree/INJICERT-13/sunbird-rc-certify-integration-impl). + * For certify: + * By default, the plugin will be taken from artifactory server + * For custom plugin: + * In the [docker compose file](docker-compose/docker-compose-certify/docker-compose.yml) uncomment the [enable_certify_artifactory](docker-compose/docker-compose-certify/docker-compose.yml#L74) and [volume](docker-compose/docker-compose-certify/docker-compose.yml#L78) + * create a folder with name certify inside loader_path folder created in the above step and add the jar file inside the folder. The JAR can be built [from source](https://github.com/mosip/digital-credential-plugins/tree/INJICERT-13/sunbird-rc-certify-integration-impl). 8. Modify the properties of the Esignet and Certify services located in the [esignet-default.properties](docker-compose/docker-compose-certify/config/esignet-default.properties) and [certify-default.properties](docker-compose/docker-compose-certify/config/certify-default.properties) files respectively. - Include Issuer ID and credential schema ID for the following properties: - esignet-default-properties: diff --git a/certify-service/Dockerfile b/certify-service/Dockerfile index 3ebdc44c..736e43eb 100644 --- a/certify-service/Dockerfile +++ b/certify-service/Dockerfile @@ -39,6 +39,9 @@ ENV is_glowroot_env=${is_glowroot} # environment variable to pass artifactory url, at docker runtime ENV artifactory_url_env=${artifactory_url} +# environment variable for certify artifactory plugins to pass at docker run time +ENV enable_certify_artifactory="true" + # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user=mosip @@ -54,7 +57,7 @@ ARG container_user_gid=1001 # install packages and create user RUN apk -q update \ -&& apk add -q unzip \ +&& apk add -q unzip sudo bash curl \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} @@ -70,6 +73,10 @@ RUN mkdir -p ${loader_path} ENV loader_path_env=${loader_path} +ADD configure_start.sh configure_start.sh + +RUN chmod +x configure_start.sh + COPY ./target/certify-service-*.jar certify-service.jar # change permissions of file inside working dir @@ -81,9 +88,10 @@ USER ${container_user_uid}:${container_user_gid} EXPOSE 8090 EXPOSE 9010 -#ENTRYPOINT [ "./configure_start.sh" ] +ENTRYPOINT [ "./configure_start.sh" ] + CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget -q --show-progress "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + wget -q "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ unzip glowroot.zip ; \ rm -rf glowroot.zip ; \ sed -i 's//idp-service/g' glowroot/glowroot.properties ; \ diff --git a/certify-service/configure_start.sh b/certify-service/configure_start.sh new file mode 100644 index 00000000..c79c4fba --- /dev/null +++ b/certify-service/configure_start.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e + +download_and_extract() { + local url=$1 + local dest_dir=$2 + shift 2 + local files_to_extract=("$@") + local temp_zip=$(mktemp) + + wget -q "$url" -O "$temp_zip" + + for file in "${files_to_extract[@]}"; do + unzip -o -j "$temp_zip" "$file" -d "$dest_dir" + done + + rm -f "$temp_zip" +} + +#if [ "$enable_esignet_artifactory" = "true" ]; then +# download_and_extract "${artifactory_url_env}/artifactory/libs-release-local/esignet/esignet-wrapper.zip" "${loader_path_env}" "esignet-mock-wrapper.jar" "sunbird-rc-esignet-integration-impl.jar" +#fi + +if [ "$enable_certify_artifactory" = "true" ]; then + download_and_extract "${artifactory_url_env}/artifactory/libs-release-local/certify/certify-plugin.zip" "${loader_path_env}" "certify-sunbird-plugin.jar" +fi + +echo "Installation complete" +cd $work_dir + +exec "$@" \ No newline at end of file diff --git a/docker-compose/docker-compose-certify/docker-compose.yml b/docker-compose/docker-compose-certify/docker-compose.yml index de778ca7..4a1aaaab 100644 --- a/docker-compose/docker-compose-certify/docker-compose.yml +++ b/docker-compose/docker-compose-certify/docker-compose.yml @@ -13,7 +13,7 @@ services: networks: - network artifactory-server: - image: 'mosipid/artifactory-server:1.4.0-ES' + image: 'mosipdev/artifactory-server:develop' ports: - 8080:8080 networks: @@ -61,20 +61,21 @@ services: networks: - network certify: - image: mosipdev/inji-certify:INJICERT-13 + image: mosipdev/inji-certify:develop user: root ports: - 8090:8090 environment: - - artifactory_url_env=http://artifactory-server:8080/ + - artifactory_url_env=http://artifactory-server:8080 - container_user=mosip - active_profile_env=default - SPRING_CONFIG_NAME=certify,certify-plugin - SPRING_CONFIG_LOCATION=/home/mosip/certify-default.properties,/home/mosip/certify-plugin-default.properties +# - enable_certify_artifactory=false volumes: - ./config/certify-default.properties:/home/mosip/certify-default.properties - ./config/certify-plugin-default.properties:/home/mosip/certify-plugin-default.properties - - ./loader_path/certify/:/home/mosip/additional_jars/ +# - ./loader_path/certify/:/home/mosip/additional_jars/ depends_on: - esignet networks: diff --git a/docker-compose/docker-compose-certify/postman-collections/certify with Sunbird RC.postman_collection.json b/docker-compose/docker-compose-certify/postman-collections/certify with Sunbird RC.postman_collection.json index 459c845d..1c58b6d1 100644 --- a/docker-compose/docker-compose-certify/postman-collections/certify with Sunbird RC.postman_collection.json +++ b/docker-compose/docker-compose-certify/postman-collections/certify with Sunbird RC.postman_collection.json @@ -889,7 +889,7 @@ } }, "url": { - "raw": "{{certifyServiceUrl}}/v1/certify/issuance/credential", + "raw": "{{certifyServiceUrl}}/issuance/credential", "host": [ "{{certifyServiceUrl}}" ],