FROM openjdk:11

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

# can be passed during Docker build as build time environment for config server URL 
ARG spring_config_name

# can be passed during Docker build as build time environment for spring server port
ARG server_port

# can be passed during Docker build as build time environment for schema name for Salt Generator 
ARG salt_gen_schema_name

# can be passed during Docker build as build time environment for table name for Salt Generator
ARG salt_gen_table_name

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

# 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 github branch to pickup configuration from, at docker runtime
ENV spring_config_name_env=${spring_config_name}

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

# environment variable to pass spring server port, at docker runtime
ENV spring_server_port=${server_port}

# environment variable to pass schema name to salt generator, at docker runtime
ENV db_url=${salt_gen_db_url}

# environment variable to pass schema name to salt generator, at docker runtime
ENV schema_name=${salt_gen_schema_name}

# environment variable to pass table name to salt generator, at docker runtime
ENV table_name=${salt_gen_table_name}

COPY ./target/kernel-salt-generator-*.jar kernel-salt-generator.jar

#EXPOSE 8092

CMD ["java","-jar","-Dspring.cloud.config.label=${spring_config_label_env}","-Dspring.cloud.config.name=${spring_config_name_env}","-Dspring.profiles.active=${active_profile_env}","-Dspring.cloud.config.uri=${spring_config_url_env}","-Dserver.port=${spring_server_port}","-Dmosip.kernel.salt-generator.db.url=${db_url}","-Dmosip.kernel.salt-generator.schemaName=${schema_name}","-Dmosip.kernel.salt-generator.tableName=${table_name}", "kernel-salt-generator.jar"]

