|
| 1 | +# ------------------------------------------------------------------------ |
| 2 | +# |
| 3 | +# Copyright 2024 WSO2, LLC. (http://wso2.com) |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License |
| 16 | +# |
| 17 | +# ------------------------------------------------------------------------ |
| 18 | + |
| 19 | +# set base Docker image to Alpine Docker image |
| 20 | +FROM alpine:3.16 |
| 21 | +LABEL maintainer= "WSO2 Docker Maintainers <[email protected]>" \ |
| 22 | + com.wso2.docker.source="https://github.com/wso2/docker-is/releases/tag/v6.1.0.5" |
| 23 | + |
| 24 | +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' |
| 25 | + |
| 26 | +# Install JDK Dependencies |
| 27 | +RUN apk add --no-cache tzdata musl-locales musl-locales-lang \ |
| 28 | + && rm -rf /var/cache/apk/* |
| 29 | + |
| 30 | +ENV JAVA_VERSION jdk-17.0.9+9.1 |
| 31 | + |
| 32 | +# Install JDK17 |
| 33 | +RUN set -eux; \ |
| 34 | + apk add --no-cache --virtual .fetch-deps curl; \ |
| 35 | + ARCH="$(apk --print-arch)"; \ |
| 36 | + case "${ARCH}" in \ |
| 37 | + amd64|x86_64) \ |
| 38 | + ESUM='c2a571a56e5bd3f30956b17b048880078c7801ed9e8754af6d1e38b9176059a9'; \ |
| 39 | + BINARY_URL='https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jdk_x64_alpine-linux_hotspot_17.0.9_9.tar.gz'; \ |
| 40 | + ;; \ |
| 41 | + *) \ |
| 42 | + echo "Unsupported arch: ${ARCH}"; \ |
| 43 | + exit 1; \ |
| 44 | + ;; \ |
| 45 | + esac; \ |
| 46 | + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ |
| 47 | + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ |
| 48 | + mkdir -p /opt/java/openjdk; \ |
| 49 | + tar --extract \ |
| 50 | + --file /tmp/openjdk.tar.gz \ |
| 51 | + --directory /opt/java/openjdk \ |
| 52 | + --strip-components 1 \ |
| 53 | + --no-same-owner \ |
| 54 | + ; \ |
| 55 | + rm -rf /tmp/openjdk.tar.gz; |
| 56 | + |
| 57 | +ENV JAVA_HOME=/opt/java/openjdk \ |
| 58 | + PATH="/opt/java/openjdk/bin:$PATH" ENV=${USER_HOME}"/.ashrc" |
| 59 | + |
| 60 | +# set Docker image build arguments |
| 61 | +# build arguments for user/group configurations |
| 62 | +ARG USER=wso2carbon |
| 63 | +ARG USER_ID=802 |
| 64 | +ARG USER_GROUP=wso2 |
| 65 | +ARG USER_GROUP_ID=802 |
| 66 | +ARG USER_HOME=/home/${USER} |
| 67 | +# build arguments for WSO2 product installation |
| 68 | +ARG WSO2_SERVER_NAME=wso2is |
| 69 | +ARG WSO2_SERVER_VERSION=6.1.0 |
| 70 | +ARG WSO2_SERVER_REPOSITORY=product-is |
| 71 | +ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION} |
| 72 | +ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER} |
| 73 | +# Hosted wso2is-6.1.0 distribution URL. |
| 74 | +ARG WSO2_SERVER_DIST_URL="" |
| 75 | +# build arguments for external artifacts |
| 76 | +ARG DNS_JAVA_VERSION=2.1.8 |
| 77 | +ARG K8S_MEMBERSHIP_SCHEME_VERSION=1.0.10 |
| 78 | +ARG MYSQL_CONNECTOR_VERSION=8.0.29 |
| 79 | +# build argument for MOTD |
| 80 | +ARG MOTD='printf "\n\ |
| 81 | + Welcome to WSO2 Docker Resources \n\ |
| 82 | + --------------------------------- \n\ |
| 83 | + This Docker container comprises of a WSO2 product, running with its latest GA release \n\ |
| 84 | + which is under the Apache License, Version 2.0. \n\ |
| 85 | + Read more about Apache License, Version 2.0 here @ http://www.apache.org/licenses/LICENSE-2.0.\n"' |
| 86 | + |
| 87 | +# create the non-root user and group and set MOTD login message |
| 88 | +RUN \ |
| 89 | + addgroup -S -g ${USER_GROUP_ID} ${USER_GROUP} \ |
| 90 | + && adduser -S -u ${USER_ID} -h ${USER_HOME} -G ${USER_GROUP} ${USER} \ |
| 91 | + && echo ${MOTD} > "${ENV}" |
| 92 | + |
| 93 | +# create Java prefs dir |
| 94 | +# this is to avoid warning logs printed by FileSystemPreferences class |
| 95 | +RUN \ |
| 96 | + mkdir -p ${USER_HOME}/.java/.systemPrefs \ |
| 97 | + && mkdir -p ${USER_HOME}/.java/.userPrefs \ |
| 98 | + && chmod -R 755 ${USER_HOME}/.java \ |
| 99 | + && chown -R ${USER}:${USER_GROUP} ${USER_HOME}/.java |
| 100 | + |
| 101 | +# copy init script to user home |
| 102 | +COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/ |
| 103 | + |
| 104 | +# install required packages |
| 105 | +RUN \ |
| 106 | + apk update \ |
| 107 | + && apk add --no-cache netcat-openbsd \ |
| 108 | + && apk add unzip \ |
| 109 | + && apk add wget |
| 110 | + |
| 111 | +RUN \ |
| 112 | + wget -O ${WSO2_SERVER}.zip "${WSO2_SERVER_DIST_URL}" \ |
| 113 | + && unzip -d ${USER_HOME} ${WSO2_SERVER}.zip \ |
| 114 | + && chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \ |
| 115 | + && rm -f ${WSO2_SERVER}.zip |
| 116 | + |
| 117 | +# add libraries for Kubernetes membership scheme based clustering |
| 118 | +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 |
| 119 | +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 |
| 120 | +# add MySQL JDBC connector to server home as a third party library |
| 121 | +ADD --chown=wso2carbon:wso2 https://repo1.maven.org/maven2/mysql/mysql-connector-java/${MYSQL_CONNECTOR_VERSION}/mysql-connector-java-${MYSQL_CONNECTOR_VERSION}.jar ${WSO2_SERVER_HOME}/repository/components/dropins/ |
| 122 | + |
| 123 | +# Set the user and work directory. |
| 124 | +USER ${USER_ID} |
| 125 | +WORKDIR ${USER_HOME} |
| 126 | + |
| 127 | +# set environment variables |
| 128 | +ENV WORKING_DIRECTORY=${USER_HOME} \ |
| 129 | + WSO2_SERVER_HOME=${WSO2_SERVER_HOME} |
| 130 | + |
| 131 | +# expose ports |
| 132 | +EXPOSE 4000 9763 9443 |
| 133 | + |
| 134 | +# initiate container and start WSO2 Carbon server |
| 135 | +ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"] |
0 commit comments