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

[MOSIP-31575] Updated docker file. #115

Closed
wants to merge 14 commits into from
104 changes: 40 additions & 64 deletions biosdk-services/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,108 +1,84 @@
FROM openjdk:11

abhishek8shankar marked this conversation as resolved.
Show resolved Hide resolved
# can be passed during Docker build as build time environment for github branch to pickup configuration from.
ARG spring_config_label

# can be passed during Docker build as build time environment for spring profiles active
ARG active_profile

# can be passed during Docker build as build time environment for config server URL
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, spring profiles active,config server URL,application name, config name and context path respectively.
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

# can be passed during Docker build as build time environment for github branch to pickup configuration from.
ARG biosdk_zip_url
ARG biosdk_local_dir=biosdk-client
ARG sdk_impl

# can be passed during Docker build as build time environment for github branch to pickup configuration from.
ARG container_user=mosip
ARG container_user_group=mosip
ARG container_user_uid=1001
ARG container_user_gid=1001

# 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

# environment variable to pass biosdk zip file path, at docker runtime
ENV biosdk_zip_file_path=${biosdk_zip_url}

ARG biosdk_local_dir=biosdk-client

# environment variable to pass biosdk local directory name, at docker runtime
ENV biosdk_local_dir_name=${biosdk_local_dir}

# environment variable to pass biosdk bioapi implementation, at docker runtime
ARG sdk_impl

ARG service_context=/biosdk-service

ENV service_context_env=${service_context}

#ENV biosdk_zip_url=$biosdk_zip_url
ENV biosdk_bioapi_impl=${sdk_impl}

# can be passed during Docker build as build time environment for github branch to pickup configuration from.
ARG container_user=mosip

# can be passed during Docker build as build time environment for github branch to pickup configuration from.
ARG container_user_group=mosip

# can be passed during Docker build as build time environment for github branch to pickup configuration from.
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}
ENV biosdk_bioapi_impl=${sdk_impl}

# 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}

# copy jar and script files
ADD ./target/biosdk-services-*.jar biosdk-services.jar

ADD ./configure_biosdk.sh configure_biosdk.sh

RUN chmod 775 biosdk-services.jar

RUN chmod +x configure_biosdk.sh

# change permissions of file inside working dir
RUN chown -R ${container_user}:${container_user} /home/${container_user}
#vinstall packages create user and change permissions of jar and script files
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} \
&& mkdir -p /home/${container_user}/additional_jars/ \
&& chmod 775 biosdk-services.jar \
&& chmod +x configure_biosdk.sh \
&& chown -R ${container_user}:${container_user} /home/${container_user}

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

# expose port and set entry point
EXPOSE 9099
ENTRYPOINT ["./configure_biosdk.sh"]

ENTRYPOINT [ "./configure_biosdk.sh" ]

# command to run the application
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="/home/${container_user}/additional_jars/" -Dbiosdk_bioapi_impl="${biosdk_bioapi_impl}" -Dlogging.level.root=${logging_level_root_env} -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dspring.application.name="${spring_application_name_env}" -Dspring.cloud.config.name=${spring_cloud_config_name_env} -Dserver.servlet.context-path=${server_servlet_context_env} biosdk-services.jar
Loading