diff --git a/dockerfiles/jdk21/ubuntu/Dockerfile b/dockerfiles/jdk21/ubuntu/Dockerfile new file mode 100644 index 00000000..25c7f875 --- /dev/null +++ b/dockerfiles/jdk21/ubuntu/Dockerfile @@ -0,0 +1,140 @@ +# ------------------------------------------------------------------------ +# +# Copyright 2024 WSO2, LLC. (http://wso2.com) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License +# +# ------------------------------------------------------------------------ + +# Set base Docker image to Ubuntu 20.04 Docker image. +FROM ubuntu:20.04 + +LABEL maintainer="WSO2 Docker Maintainers " \ + com.wso2.docker.source="https://github.com/wso2/docker-is/releases/tag/v7.1.0-m3" + +# Install JDK Dependencies. +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt-get update \ + && apt-get install -y --no-install-recommends tzdata curl ca-certificates fontconfig locales \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION jdk-21.0.4+7 + +# Install JDK21. +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ + case "${ARCH}" in \ + amd64|x86_64) \ + ESUM='51fb4d03a4429c39d397d3a03a779077159317616550e4e71624c9843083e7b9'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.4%2B7/OpenJDK21U-jdk_x64_linux_hotspot_21.0.4_7.tar.gz'; \ + ;; \ + aarch64|arm64) \ + ESUM='d768eecddd7a515711659e02caef8516b7b7177fa34880a56398fd9822593a79'; \ + BINARY_URL='https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.4%2B7/OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.4_7.tar.gz'; \ + ;; \ + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + curl -LfsSo /tmp/openjdk.tar.gz ${BINARY_URL}; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p /opt/java/openjdk; \ + cd /opt/java/openjdk; \ + tar -xf /tmp/openjdk.tar.gz --strip-components=1; \ + rm -rf /tmp/openjdk.tar.gz; + +ENV JAVA_HOME=/opt/java/openjdk \ + PATH="/opt/java/openjdk/bin:$PATH" + +# Set Docker image build arguments. +# Build arguments for user/group configurations. +ARG USER=wso2carbon +ARG USER_ID=802 +ARG USER_GROUP=wso2 +ARG USER_GROUP_ID=802 +ARG USER_HOME=/home/${USER} +# Build arguments for WSO2 product installation. +ARG WSO2_SERVER_NAME=wso2is +ARG WSO2_SERVER_VERSION=7.1.0-m3 +# Hosted wso2is-7.1.0-m3 distribution URL. +ARG WSO2_SERVER_DIST_URL=https://github.com/wso2/${WSO2_SERVER_REPOSITORY}/releases/download/v${WSO2_SERVER_VERSION}/${WSO2_SERVER}.zip +ARG WSO2_SERVER_REPOSITORY=product-is +ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION} +ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER} +# Hosted wso2is-7.1.0-m3 distribution URL. +ARG WSO2_SERVER_DIST_URL=https://github.com/wso2/${WSO2_SERVER_REPOSITORY}/releases/download/v${WSO2_SERVER_VERSION}/${WSO2_SERVER}.zip +# Build arguments for external artifacts. +ARG DNS_JAVA_VERSION=3.6.1 +ARG K8S_MEMBERSHIP_SCHEME_VERSION=1.0.10 +# Build argument for MOTD. +ARG MOTD="\n\ +Welcome to WSO2 Docker resources.\n\ +------------------------------------ \n\ +This Docker container comprises of a WSO2 product, running with its latest GA release \n\ +which is under the Apache License, Version 2.0. \n\ +Read more about Apache License, Version 2.0 here @ http://www.apache.org/licenses/LICENSE-2.0.\n" + +# Create the non-root user and group and set MOTD login message. +RUN \ + groupadd --system -g ${USER_GROUP_ID} ${USER_GROUP} \ + && useradd --system --create-home --home-dir ${USER_HOME} --no-log-init -g ${USER_GROUP_ID} -u ${USER_ID} ${USER} \ + && echo '[ ! -z "${TERM}" -a -r /etc/motd ] && cat /etc/motd' >> /etc/bash.bashrc; echo "${MOTD}" > /etc/motd + +# Create Java prefs dir. +# This is to avoid warning logs printed by FileSystemPreferences class. +RUN \ + mkdir -p ${USER_HOME}/.java/.systemPrefs \ + && mkdir -p ${USER_HOME}/.java/.userPrefs \ + && chmod -R 755 ${USER_HOME}/.java \ + && chown -R ${USER}:${USER_GROUP} ${USER_HOME}/.java + +# Copy init script to user home. +COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/ + +# Install required packages. +RUN \ + apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + netcat \ + unzip \ + wget \ + && rm -rf /var/lib/apt/lists/* + +RUN \ + wget -O ${WSO2_SERVER}.zip "${WSO2_SERVER_DIST_URL}" \ + && unzip -d ${USER_HOME} ${WSO2_SERVER}.zip \ + && chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \ + && rm -f ${WSO2_SERVER}.zip + +# Add libraries for Kubernetes membership scheme based clustering. +ADD --chown=wso2carbon:wso2 https://repo1.maven.org/maven2/dnsjava/dnsjava/${DNS_JAVA_VERSION}/dnsjava-${DNS_JAVA_VERSION}.jar ${WSO2_SERVER_HOME}/repository/components/lib +ADD --chown=wso2carbon:wso2 http://maven.wso2.org/nexus/content/repositories/releases/org/wso2/carbon/kubernetes/artifacts/kubernetes-membership-scheme/${K8S_MEMBERSHIP_SCHEME_VERSION}/kubernetes-membership-scheme-${K8S_MEMBERSHIP_SCHEME_VERSION}.jar ${WSO2_SERVER_HOME}/repository/components/dropins + +# Set the user and work directory. +USER ${USER_ID} +WORKDIR ${USER_HOME} + +# Set environment variables. +ENV JAVA_OPTS="-Djava.util.prefs.systemRoot=${USER_HOME}/.java -Djava.util.prefs.userRoot=${USER_HOME}/.java/.userPrefs" \ + WORKING_DIRECTORY=${USER_HOME} \ + WSO2_SERVER_HOME=${WSO2_SERVER_HOME} + +# Expose ports. +EXPOSE 4000 9763 9443 + +# Initiate container and start WSO2 Carbon server. +ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"] diff --git a/dockerfiles/jdk21/ubuntu/docker-entrypoint.sh b/dockerfiles/jdk21/ubuntu/docker-entrypoint.sh new file mode 100755 index 00000000..5228d622 --- /dev/null +++ b/dockerfiles/jdk21/ubuntu/docker-entrypoint.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# ------------------------------------------------------------------------ +# Copyright 2024 WSO2, LLC. (http://wso2.com) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License +# ------------------------------------------------------------------------ + +set -e + +# Volume mounts. +config_volume=${WORKING_DIRECTORY}/wso2-config-volume +artifact_volume=${WORKING_DIRECTORY}/wso2-artifact-volume + +# Check if the WSO2 non-root user home exists. +test ! -d ${WORKING_DIRECTORY} && echo "WSO2 Docker non-root user home does not exist" && exit 1 + +# Check if the WSO2 product home exists. +test ! -d ${WSO2_SERVER_HOME} && echo "WSO2 Docker product home does not exist" && exit 1 + +# Copy any configuration changes mounted to config_volume. +test -d ${config_volume} && [ "$(ls -A ${config_volume})" ] && cp -RL ${config_volume}/* ${WSO2_SERVER_HOME}/ +# Copy any artifact changes mounted to artifact_volume. +test -d ${artifact_volume} && [ "$(ls -A ${artifact_volume})" ] && cp -RL ${artifact_volume}/* ${WSO2_SERVER_HOME}/ + +# Start WSO2 Carbon server. +sh ${WSO2_SERVER_HOME}/bin/wso2server.sh "$@"