ARG webup_payara_version
FROM payara/server-full:${webup_payara_version}

ARG webup_asadmin_Xms
ARG webup_asadmin_Xmx
ARG webup_asadmin_MetaspaceSize
ARG webup_asadmin_MaxMetaspaceSize
ARG webup_asadmin_rejectClientInitiatedRenegotiation
ARG webup_asadmin_classloadingDelegate
ARG webup_asadmin_GC
ARG	webup_asadmin_stringDuplication
ARG	webup_asadmin_disableExplicitGC
ARG	webup_asadmin_autodeployEnabled
ARG	webup_asadmin_dynamicReload
ARG	webup_asadmin_poolResizeQuantity
ARG	webup_asadmin_maxPoolSize
ARG	webup_asadmin_steadyPoolSize
ARG	webup_asadmin_minThreadPoolSize
ARG	webup_asadmin_maxThreadPoolSize
ARG	webup_asadmin_httpListener1Enabled
ARG	webup_asadmin_httpListener2Enabled
ARG	webup_asadmin_httpMaxConnections
ARG	webup_asadmin_httpTimeoutSeconds
ARG	webup_asadmin_httpFileCacheMaxAgeSeconds
ARG	webup_asadmin_httpFileCacheEnabled
ARG	webup_asadmin_acceptorThreads
ARG	webup_asadmin_httpThreadPoolMinThreadPoolSize
ARG	webup_asadmin_httpThreadPoolMaxThreadPoolSize
ARG webup_asadmin_loggingGFFileHandlerLogtoFile
ARG webup_asadmin_loggingGFFileHandlerRotationLimitInBytes
ARG webup_asadmin_loggingGFFileHandlerMaxHistoryFiles
ARG webup_asadmin_hazelcastEnabled
ARG webup_asadmin_hazelcastDynamic
ARG webup_asadmin_httpMaxFormPostSizeBytes
ARG webup_asadmin_httpXpoweredBy
ARG webup_asadmin_httpSchemeMapping
ARG webup_asadmin_disableJSPServletDevelopment
ARG webup_asadmin_JSPServletStrAsCharArray
ARG webup_asadmin_dumpIfOutOfMemory
ARG webup_asadmin_jfr

# Set payara settings
ENV webup_asadmin_Xms=${webup_asadmin_Xms}
ENV webup_asadmin_Xmx=${webup_asadmin_Xmx}
ENV webup_asadmin_MetaspaceSize=${webup_asadmin_MetaspaceSize}
ENV webup_asadmin_MaxMetaspaceSize=${webup_asadmin_MaxMetaspaceSize}
ENV webup_asadmin_rejectClientInitiatedRenegotiation=${webup_asadmin_rejectClientInitiatedRenegotiation}
ENV webup_asadmin_classloadingDelegate=${webup_asadmin_classloadingDelegate}
ENV webup_asadmin_GC=${webup_asadmin_GC}
ENV	webup_asadmin_stringDuplication=${webup_asadmin_stringDuplication}
ENV	webup_asadmin_disableExplicitGC=${webup_asadmin_disableExplicitGC}
ENV	webup_asadmin_autodeployEnabled=${webup_asadmin_autodeployEnabled}
ENV	webup_asadmin_dynamicReload=${webup_asadmin_dynamicReload}
ENV	webup_asadmin_poolResizeQuantity=${webup_asadmin_poolResizeQuantity}
ENV	webup_asadmin_maxPoolSize=${webup_asadmin_maxPoolSize}
ENV	webup_asadmin_steadyPoolSize=${webup_asadmin_steadyPoolSize}
ENV	webup_asadmin_minThreadPoolSize=${webup_asadmin_minThreadPoolSize}
ENV	webup_asadmin_maxThreadPoolSize=${webup_asadmin_maxThreadPoolSize}
ENV	webup_asadmin_httpListener1Enabled=${webup_asadmin_httpListener1Enabled}
ENV	webup_asadmin_httpListener2Enabled=${webup_asadmin_httpListener2Enabled}
ENV	webup_asadmin_httpMaxConnections=${webup_asadmin_httpMaxConnections}
ENV	webup_asadmin_httpTimeoutSeconds=${webup_asadmin_httpTimeoutSeconds}
ENV	webup_asadmin_httpFileCacheMaxAgeSeconds=${webup_asadmin_httpFileCacheMaxAgeSeconds}
ENV	webup_asadmin_httpFileCacheEnabled=${webup_asadmin_httpFileCacheEnabled}
ENV	webup_asadmin_acceptorThreads=${webup_asadmin_acceptorThreads}
ENV	webup_asadmin_httpThreadPoolMinThreadPoolSize=${webup_asadmin_httpThreadPoolMinThreadPoolSize}
ENV	webup_asadmin_httpThreadPoolMaxThreadPoolSize=${webup_asadmin_httpThreadPoolMaxThreadPoolSize}
ENV webup_asadmin_loggingGFFileHandlerLogtoFile=${webup_asadmin_loggingGFFileHandlerLogtoFile}
ENV webup_asadmin_loggingGFFileHandlerRotationLimitInBytes=${webup_asadmin_loggingGFFileHandlerRotationLimitInBytes}
ENV webup_asadmin_loggingGFFileHandlerMaxHistoryFiles=${webup_asadmin_loggingGFFileHandlerMaxHistoryFiles}
ENV webup_asadmin_hazelcastEnabled=${webup_asadmin_hazelcastEnabled}
ENV webup_asadmin_hazelcastDynamic=${webup_asadmin_hazelcastDynamic}
ENV webup_asadmin_httpMaxFormPostSizeBytes=${webup_asadmin_httpMaxFormPostSizeBytes}
ENV webup_asadmin_httpXpoweredBy=${webup_asadmin_httpXpoweredBy}
ENV webup_asadmin_httpSchemeMapping=${webup_asadmin_httpSchemeMapping}
ENV webup_asadmin_disableJSPServletDevelopment=${webup_asadmin_disableJSPServletDevelopment}
ENV webup_asadmin_JSPServletStrAsCharArray=${webup_asadmin_JSPServletStrAsCharArray}
ENV webup_asadmin_dumpIfOutOfMemory=${webup_asadmin_dumpIfOutOfMemory}
ENV webup_asadmin_jfr=${webup_asadmin_jfr}

RUN mkdir -p etc/webup
RUN mkdir -p etc/webup-postboot
RUN mkdir -p var/webup

# Set post boot command for webup war deploy
ENV POSTBOOT_COMMANDS_FINAL=etc/webup-postboot/webup-post-boot-commands

# Configure payara

ENV AS_ADMIN ${PAYARA_DIR}/bin/asadmin 


# Create payara's configurations

## note: server option is already present in 5.2021.9 version

ENV asadmin_command=""
ADD setAsadminVars.sh /tmp
RUN /tmp/setAsadminVars.sh


# Define ENTRYPOINT
 
USER payara
ENTRYPOINT /opt/payara/scripts/startInForeground.sh
