Skip to content

Commit

Permalink
Use OpenJ9's system SCC
Browse files Browse the repository at this point in the history
OpenJ9 images now ship with an SCC that we can
use as a base SCC layer.
  • Loading branch information
ymanton committed Sep 25, 2020
1 parent f00edd9 commit 17c40f9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
3 changes: 1 addition & 2 deletions releases/latest/kernel/Dockerfile.ubi.adoptopenjdk11
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ RUN if [ "$OPENJ9_SCC" = "true" ]; then populate_scc.sh; fi \
&& chmod -R g+rwx /opt/ol/wlp/output

#These settings are needed so that we can run as a different user than 1001 after server warmup
ENV RANDFILE=/tmp/.rnd \
IBM_JAVA_OPTIONS="-Xshareclasses:name=liberty,nonfatal,cacheDir=/output/.classCache/ ${IBM_JAVA_OPTIONS}"
ENV RANDFILE=/tmp/.rnd

USER 1001

Expand Down
3 changes: 1 addition & 2 deletions releases/latest/kernel/Dockerfile.ubi.adoptopenjdk14
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ RUN if [ "$OPENJ9_SCC" = "true" ]; then populate_scc.sh; fi \
&& chmod -R g+rwx /opt/ol/wlp/output

#These settings are needed so that we can run as a different user than 1001 after server warmup
ENV RANDFILE=/tmp/.rnd \
IBM_JAVA_OPTIONS="-Xshareclasses:name=liberty,nonfatal,cacheDir=/output/.classCache/ ${IBM_JAVA_OPTIONS}"
ENV RANDFILE=/tmp/.rnd

USER 1001

Expand Down
3 changes: 1 addition & 2 deletions releases/latest/kernel/Dockerfile.ubi.adoptopenjdk8
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ RUN if [ "$OPENJ9_SCC" = "true" ]; then populate_scc.sh; fi \
&& chmod -R g+rwx /opt/ol/wlp/output

#These settings are needed so that we can run as a different user than 1001 after server warmup
ENV RANDFILE=/tmp/.rnd \
IBM_JAVA_OPTIONS="-Xshareclasses:name=liberty,nonfatal,cacheDir=/output/.classCache/ ${IBM_JAVA_OPTIONS}"
ENV RANDFILE=/tmp/.rnd

USER 1001

Expand Down
3 changes: 1 addition & 2 deletions releases/latest/kernel/Dockerfile.ubuntu.adoptopenjdk8
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ RUN if [ "$OPENJ9_SCC" = "true" ]; then populate_scc.sh; fi \
&& chmod -R g+rwx /opt/ol/wlp/output

#These settings are needed so that we can run as a different user than 1001 after server warmup
ENV RANDFILE=/tmp/.rnd \
IBM_JAVA_OPTIONS="-Xshareclasses:name=liberty,nonfatal,cacheDir=/output/.classCache/ ${IBM_JAVA_OPTIONS}"
ENV RANDFILE=/tmp/.rnd

USER 1001

Expand Down
24 changes: 20 additions & 4 deletions releases/latest/kernel/helpers/build/populate_scc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ TRIM_SCC=yes # Trim the SCC to eliminate any wasted space.
# In order to reduce the chances of this happening we use the -XX:+OriginalJDK8HeapSizeCompatibilityMode
# option to revert to the old criteria, which results in AOT code that is more compatible, on average, with typical heap sizes/positions.
# The option has no effect on later JDKs.
export IBM_JAVA_OPTIONS="-XX:+OriginalJDK8HeapSizeCompatibilityMode -Xshareclasses:name=liberty,cacheDir=/output/.classCache/"
CREATE_LAYER="$IBM_JAVA_OPTIONS,createLayer,groupAccess"
DESTROY_LAYER="$IBM_JAVA_OPTIONS,destroy"
PRINT_LAYER_STATS="$IBM_JAVA_OPTIONS,printTopLayerStats"
if [[ -d "/opt/java/.scc" ]]
then
# If this directory exists, assume we're running on an OpenJ9 container with an SCC that we can build on.
export OPENJ9_JAVA_OPTIONS="-XX:+OriginalJDK8HeapSizeCompatibilityMode -Xshareclasses:name=openj9_system_scc,cacheDir=/opt/java/.scc"
CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess"
DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy"
PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats"
else
# If not, assume we're running on the IBM JDK which doesn't ship with an SCC, hence we build our own.
export IBM_JAVA_OPTIONS="-XX:+OriginalJDK8HeapSizeCompatibilityMode -Xshareclasses:name=liberty,cacheDir=/output/.classCache/"
CREATE_LAYER="$IBM_JAVA_OPTIONS,createLayer,groupAccess"
DESTROY_LAYER="$IBM_JAVA_OPTIONS,destroy"
PRINT_LAYER_STATS="$IBM_JAVA_OPTIONS,printTopLayerStats"
fi

while getopts ":i:s:tdh" OPT
do
Expand Down Expand Up @@ -60,6 +70,12 @@ do
esac
done

# We need to make the OpenJ9 SCC directory group accessible
if [[ $EUID -eq 0 ]] && [[ -d "/opt/java/.scc" ]]
then
chmod g+rwx /opt/java/.scc
fi

OLD_UMASK=`umask`
umask 002 # 002 is required to provide group rw permission to the cache when `-Xshareclasses:groupAccess` options is used

Expand Down

0 comments on commit 17c40f9

Please sign in to comment.