From 48b58f0695e598ff1dd53b359bffaec3d1b627db Mon Sep 17 00:00:00 2001 From: Tharika Madurapperuma Date: Sat, 5 Feb 2022 09:35:52 +0530 Subject: [PATCH 1/4] add support to build jdk8 images --- CHANGELOG.md | 5 ++ dockerfiles/jdk8/alpine/apim/Dockerfile | 85 ++++++++++++++++++ dockerfiles/jdk8/alpine/apim/README.md | 74 ++++++++++++++++ .../jdk8/alpine/apim/docker-entrypoint.sh | 73 ++++++++++++++++ dockerfiles/jdk8/centos/apim/Dockerfile | 85 ++++++++++++++++++ dockerfiles/jdk8/centos/apim/README.md | 75 ++++++++++++++++ .../jdk8/centos/apim/docker-entrypoint.sh | 73 ++++++++++++++++ dockerfiles/jdk8/ubuntu/apim/Dockerfile | 87 +++++++++++++++++++ dockerfiles/jdk8/ubuntu/apim/README.md | 74 ++++++++++++++++ .../jdk8/ubuntu/apim/docker-entrypoint.sh | 73 ++++++++++++++++ 10 files changed, 704 insertions(+) create mode 100755 dockerfiles/jdk8/alpine/apim/Dockerfile create mode 100755 dockerfiles/jdk8/alpine/apim/README.md create mode 100755 dockerfiles/jdk8/alpine/apim/docker-entrypoint.sh create mode 100755 dockerfiles/jdk8/centos/apim/Dockerfile create mode 100755 dockerfiles/jdk8/centos/apim/README.md create mode 100755 dockerfiles/jdk8/centos/apim/docker-entrypoint.sh create mode 100755 dockerfiles/jdk8/ubuntu/apim/Dockerfile create mode 100755 dockerfiles/jdk8/ubuntu/apim/README.md create mode 100755 dockerfiles/jdk8/ubuntu/apim/docker-entrypoint.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index af10d895..cbc5498b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to Docker and Docker Compose resources for WSO2 API Manageme The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [v4.0.0.2] - 2022-02-05 + +### Changed +- Change folder structure of dockerfile locations and introduced separate images for jdk8 and jdk11 (refer to [issue](https://github.com/wso2/product-apim/issues/12223) + ## [v4.0.0.2] - 2021-6-14 ### Changed diff --git a/dockerfiles/jdk8/alpine/apim/Dockerfile b/dockerfiles/jdk8/alpine/apim/Dockerfile new file mode 100755 index 00000000..d7669c69 --- /dev/null +++ b/dockerfiles/jdk8/alpine/apim/Dockerfile @@ -0,0 +1,85 @@ +# ------------------------------------------------------------------------ +# +# Copyright 2018 WSO2, Inc. (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 AdoptOpenJDK Alpine Docker image +FROM adoptopenjdk/openjdk8:jdk8u292-b10-alpine +LABEL maintainer="WSO2 Docker Maintainers " \ + com.wso2.docker.source="https://github.com/wso2/docker-apim/releases/tag/v4.0.0.2" + +# 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=wso2am +ARG WSO2_SERVER_VERSION=4.0.0 +ARG WSO2_SERVER_REPOSITORY=product-apim +ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION} +ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER} +ARG WSO2_SERVER_DIST_URL=https://github.com/wso2/${WSO2_SERVER_REPOSITORY}/releases/download/v${WSO2_SERVER_VERSION}/${WSO2_SERVER}.zip +# build argument for MOTD +ARG MOTD='printf "\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"' +ENV ENV=${USER_HOME}"/.ashrc" + +# create the non-root user and group and set MOTD login message +RUN \ + addgroup -S -g ${USER_GROUP_ID} ${USER_GROUP} \ + && adduser -S -u ${USER_ID} -h ${USER_HOME} -G ${USER_GROUP} ${USER} \ + && echo ${MOTD} > "${ENV}" + +# copy init script to user home +COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/ +# install required packages +RUN \ + apk add --no-cache \ + bash \ + libxml2-utils \ + netcat-openbsd +# add the WSO2 product distribution to user's home directory +RUN \ + wget -O ${WSO2_SERVER}.zip "${WSO2_SERVER_DIST_URL}" \ + && unzip -d ${USER_HOME} ${WSO2_SERVER}.zip \ + && chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \ + && mkdir ${USER_HOME}/wso2-tmp \ + && bash -c 'mkdir -p ${USER_HOME}/solr/{indexed-data,database}' \ + && chown wso2carbon:wso2 -R ${USER_HOME}/solr \ + && cp -r ${WSO2_SERVER_HOME}/repository/deployment/server/synapse-configs ${USER_HOME}/wso2-tmp \ + && cp -r ${WSO2_SERVER_HOME}/repository/deployment/server/executionplans ${USER_HOME}/wso2-tmp \ + && rm -f ${WSO2_SERVER}.zip + +# set the user and work directory +USER ${USER_ID} +WORKDIR ${USER_HOME} + +# set environment variables +ENV WORKING_DIRECTORY=${USER_HOME} \ + WSO2_SERVER_HOME=${WSO2_SERVER_HOME} + +# expose ports +EXPOSE 9763 9443 9999 11111 8280 8243 5672 9711 9611 9099 + +# initiate container and start WSO2 Carbon server +ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"] diff --git a/dockerfiles/jdk8/alpine/apim/README.md b/dockerfiles/jdk8/alpine/apim/README.md new file mode 100755 index 00000000..b489f119 --- /dev/null +++ b/dockerfiles/jdk8/alpine/apim/README.md @@ -0,0 +1,74 @@ +# Dockerfile for WSO2 API Manager # + +This section defines the step-by-step instructions to build an [Alpine](https://hub.docker.com/_/alpine/) Linux based Docker image for WSO2 API Manager 4.0.0. + +## Prerequisites + +* [Docker](https://www.docker.com/get-docker) v17.09.0 or above +* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) client + +## How to build an image and run + +##### 1. Checkout this repository into your local machine using the following Git client command. + +``` +git clone https://github.com/wso2/docker-apim.git +``` + +> The local copy of the `dockerfiles/alpine/apim` directory will be referred to as `AM_DOCKERFILE_HOME` from this point onwards. + +##### 2. Build the Docker image. + +- Navigate to `` directory.
+ Execute `docker build` command as shown below. + + `docker build -t wso2am:4.0.0-alpine .` + +> By default, the Docker image will prepackage the General Availability (GA) release version of the relevant WSO2 product. + +##### 3. Running the Docker image. + +- `docker run -it -p 9443:9443 wso2am:4.0.0-alpine` + +> Here, only port 9443 (HTTPS servlet transport) has been mapped to a Docker host port. +You may map other container service ports, which have been exposed to Docker host ports, as desired. + +##### 4. Accessing management console. + +- To access the management console, use the docker host IP and port 9443. + + `https://:9443/carbon` + +> In here, refers to hostname or IP of the host machine on top of which containers are spawned. + +## How to update configurations + +Configurations would lie on the Docker host machine and they can be volume mounted to the container.
+As an example, steps required to change the port offset using `deployment.toml` is as follows: + +##### 1. Stop the API Manager container if it's already running. + +In WSO2 API Manager version 4.0.0 product distribution, `deployment.toml` configuration file
+can be found at `/repository/conf`. Copy the file to some suitable location of the host machine,
+referred to as `/deployment.toml` and change the offset value (`[server]->offset`) to 1. + +##### 2. Grant read permission to `other` users for `/deployment.toml`. + +``` +chmod o+r /deployment.toml +``` + +##### 3. Run the image by mounting the file to container as follows: + +``` +docker run \ +-p 9444:9444 \ +--volume /deployment.toml:/deployment.toml \ +wso2am:4.0.0-alpine +``` + +> In here, refers to /home/wso2carbon/wso2am-4.0.0/repository/conf folder of the container. + +## Docker command usage references + +* [Docker build command reference](https://docs.docker.com/engine/reference/commandline/build/) +* [Docker run command reference](https://docs.docker.com/engine/reference/run/) +* [Dockerfile reference](https://docs.docker.com/engine/reference/builder/) diff --git a/dockerfiles/jdk8/alpine/apim/docker-entrypoint.sh b/dockerfiles/jdk8/alpine/apim/docker-entrypoint.sh new file mode 100755 index 00000000..2bf2dcfc --- /dev/null +++ b/dockerfiles/jdk8/alpine/apim/docker-entrypoint.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# ------------------------------------------------------------------------ +# Copyright 2018 WSO2, Inc. (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 +# home of the directories to be artifact synced within the WSO2 product home +deployment_volume=${WSO2_SERVER_HOME}/repository/deployment/server +# home of the directories with preserved, default deployment artifacts +original_deployment_artifacts=${WORKING_DIRECTORY}/wso2-tmp + +# 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 + +# shared artifact directories +directories=("executionplans" "synapse-configs") +# if the original directory locations of artifacts to be synced between nodes are empty, +# copy the preserved, default content of these folders to these original locations +for shared_directory in ${directories[@]}; do + if test -d ${original_deployment_artifacts}/${shared_directory}; + then + if [[ -z "$(ls -A ${deployment_volume}/${shared_directory})" ]]; then + if ! cp -R ${original_deployment_artifacts}/${shared_directory}/* ${deployment_volume}/${shared_directory}; + then + echo "Failed to copy the preserved, default artifacts to original location (${deployment_volume}/${shared_directory})" + exit 1 + fi + echo "Successfully copied the preserved, default artifacts to original location (${deployment_volume}/${shared_directory})" + fi + fi +done + +# optimize WSO2 Carbon Server, if the profile name is defined as an environment variable +if [[ ! -z "${PROFILE_NAME}" ]] +then + echo "Optimizing WSO2 Carbon Server" >&2 + sh ${WSO2_SERVER_HOME}/bin/profileSetup.sh -Dprofile=${PROFILE_NAME} +fi + +# 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 +echo "Start WSO2 Carbon server" >&2 +if [[ -z "${PROFILE_NAME}" ]] +then + # start the server with the provided startup arguments + sh ${WSO2_SERVER_HOME}/bin/api-manager.sh "$@" +else + # start the server with the specified profile and provided startup arguments + sh ${WSO2_SERVER_HOME}/bin/api-manager.sh -Dprofile=${PROFILE_NAME} "$@" +fi diff --git a/dockerfiles/jdk8/centos/apim/Dockerfile b/dockerfiles/jdk8/centos/apim/Dockerfile new file mode 100755 index 00000000..b390dc9a --- /dev/null +++ b/dockerfiles/jdk8/centos/apim/Dockerfile @@ -0,0 +1,85 @@ +# ------------------------------------------------------------------------ +# +# Copyright 2018 WSO2, Inc. (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 AdoptOpenJDK CentOS Docker image +FROM adoptopenjdk/openjdk8:jdk8u292-b10-centos +LABEL maintainer="WSO2 Docker Maintainers " \ + com.wso2.docker.source="https://github.com/wso2/docker-apim/releases/tag/v4.0.0.2" +# 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=wso2am +ARG WSO2_SERVER_VERSION=4.0.0 +ARG WSO2_SERVER_REPOSITORY=product-apim +ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION} +ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER} +ARG WSO2_SERVER_DIST_URL=https://github.com/wso2/${WSO2_SERVER_REPOSITORY}/releases/download/v${WSO2_SERVER_VERSION}/${WSO2_SERVER}.zip +# build argument for MOTD +ARG MOTD='printf "\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\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 ${MOTD} > /etc/profile.d/motd.sh + +# copy init script to user home +COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/ +# install required packages +RUN \ + yum -y update \ + && yum install -y \ + nc \ + unzip \ + wget \ + && rm -rf /var/cache/yum/* +# add the WSO2 product distribution to user's home directory +RUN \ + wget -O ${WSO2_SERVER}.zip "${WSO2_SERVER_DIST_URL}" \ + && unzip -d ${USER_HOME} ${WSO2_SERVER}.zip \ + && chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \ + && mkdir ${USER_HOME}/wso2-tmp \ + && bash -c 'mkdir -p ${USER_HOME}/solr/{indexed-data,database}' \ + && chown wso2carbon:wso2 -R ${USER_HOME}/solr \ + && cp -r ${WSO2_SERVER_HOME}/repository/deployment/server/synapse-configs ${USER_HOME}/wso2-tmp \ + && cp -r ${WSO2_SERVER_HOME}/repository/deployment/server/executionplans ${USER_HOME}/wso2-tmp \ + && rm -f ${WSO2_SERVER}.zip + +# set the user and work directory +USER ${USER_ID} +WORKDIR ${USER_HOME} + +# set environment variables +ENV WORKING_DIRECTORY=${USER_HOME} \ + WSO2_SERVER_HOME=${WSO2_SERVER_HOME} + +# expose ports +EXPOSE 9763 9443 9999 11111 8280 8243 5672 9711 9611 9099 + +# initiate container and start WSO2 Carbon server +ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"] diff --git a/dockerfiles/jdk8/centos/apim/README.md b/dockerfiles/jdk8/centos/apim/README.md new file mode 100755 index 00000000..ba603475 --- /dev/null +++ b/dockerfiles/jdk8/centos/apim/README.md @@ -0,0 +1,75 @@ +# Dockerfile for WSO2 API Manager # + +This section defines the step-by-step instructions to build an [CentOS](https://hub.docker.com/_/centos/) Linux based Docker image for WSO2 API Manager 4.0.0. + +## Prerequisites + +* [Docker](https://www.docker.com/get-docker) v17.09.0 or above +* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) client + + +## How to build an image and run + +##### 1. Checkout this repository into your local machine using the following Git client command. + +``` +git clone https://github.com/wso2/docker-apim.git +``` + +> The local copy of the `dockerfiles/centos/apim` directory will be referred to as `AM_DOCKERFILE_HOME` from this point onwards. + +##### 2. Build the Docker image. + +- Navigate to `` directory.
+ Execute `docker build` command as shown below. + + `docker build -t wso2am:4.0.0-centos .` + +> By default, the Docker image will prepackage the General Availability (GA) release version of the relevant WSO2 product. + +##### 3. Running the Docker image. + +- `docker run -it -p 9443:9443 wso2am:4.0.0-centos` + +> Here, only port 9443 (HTTPS servlet transport) has been mapped to a Docker host port. +You may map other container service ports, which have been exposed to Docker host ports, as desired. + +##### 4. Accessing management console. + +- To access the management console, use the docker host IP and port 9443. + + `https://:9443/carbon` + +> In here, refers to hostname or IP of the host machine on top of which containers are spawned. + +## How to update configurations + +Configurations would lie on the Docker host machine and they can be volume mounted to the container.
+As an example, steps required to change the port offset using `deployment.toml` is as follows: + +##### 1. Stop the API Manager container if it's already running. + +In WSO2 API Manager version 4.0.0 product distribution, `deployment.toml` configuration file
+can be found at `/repository/conf`. Copy the file to some suitable location of the host machine,
+referred to as `/deployment.toml` and change the offset value (`[server]->offset`) to 1. + +##### 2. Grant read permission to `other` users for `/deployment.toml`. + +``` +chmod o+r /deployment.toml +``` + +##### 3. Run the image by mounting the file to container as follows: + +``` +docker run \ +-p 9444:9444 \ +--volume /deployment.toml:/deployment.toml \ +wso2am:4.0.0-centos +``` + +> In here, refers to /home/wso2carbon/wso2am-4.0.0/repository/conf folder of the container. + +## Docker command usage references + +* [Docker build command reference](https://docs.docker.com/engine/reference/commandline/build/) +* [Docker run command reference](https://docs.docker.com/engine/reference/run/) +* [Dockerfile reference](https://docs.docker.com/engine/reference/builder/) diff --git a/dockerfiles/jdk8/centos/apim/docker-entrypoint.sh b/dockerfiles/jdk8/centos/apim/docker-entrypoint.sh new file mode 100755 index 00000000..2bf2dcfc --- /dev/null +++ b/dockerfiles/jdk8/centos/apim/docker-entrypoint.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# ------------------------------------------------------------------------ +# Copyright 2018 WSO2, Inc. (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 +# home of the directories to be artifact synced within the WSO2 product home +deployment_volume=${WSO2_SERVER_HOME}/repository/deployment/server +# home of the directories with preserved, default deployment artifacts +original_deployment_artifacts=${WORKING_DIRECTORY}/wso2-tmp + +# 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 + +# shared artifact directories +directories=("executionplans" "synapse-configs") +# if the original directory locations of artifacts to be synced between nodes are empty, +# copy the preserved, default content of these folders to these original locations +for shared_directory in ${directories[@]}; do + if test -d ${original_deployment_artifacts}/${shared_directory}; + then + if [[ -z "$(ls -A ${deployment_volume}/${shared_directory})" ]]; then + if ! cp -R ${original_deployment_artifacts}/${shared_directory}/* ${deployment_volume}/${shared_directory}; + then + echo "Failed to copy the preserved, default artifacts to original location (${deployment_volume}/${shared_directory})" + exit 1 + fi + echo "Successfully copied the preserved, default artifacts to original location (${deployment_volume}/${shared_directory})" + fi + fi +done + +# optimize WSO2 Carbon Server, if the profile name is defined as an environment variable +if [[ ! -z "${PROFILE_NAME}" ]] +then + echo "Optimizing WSO2 Carbon Server" >&2 + sh ${WSO2_SERVER_HOME}/bin/profileSetup.sh -Dprofile=${PROFILE_NAME} +fi + +# 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 +echo "Start WSO2 Carbon server" >&2 +if [[ -z "${PROFILE_NAME}" ]] +then + # start the server with the provided startup arguments + sh ${WSO2_SERVER_HOME}/bin/api-manager.sh "$@" +else + # start the server with the specified profile and provided startup arguments + sh ${WSO2_SERVER_HOME}/bin/api-manager.sh -Dprofile=${PROFILE_NAME} "$@" +fi diff --git a/dockerfiles/jdk8/ubuntu/apim/Dockerfile b/dockerfiles/jdk8/ubuntu/apim/Dockerfile new file mode 100755 index 00000000..7ddae151 --- /dev/null +++ b/dockerfiles/jdk8/ubuntu/apim/Dockerfile @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------ +# +# Copyright 2017 WSO2, Inc. (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 AdoptOpenJDK Ubuntu Docker image +FROM adoptopenjdk:8u292-b10-jdk-hotspot-focal +LABEL maintainer="WSO2 Docker Maintainers " \ + com.wso2.docker.source="https://github.com/wso2/docker-apim/releases/tag/v4.0.0.2" + +# 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=wso2am +ARG WSO2_SERVER_VERSION=4.0.0 +ARG WSO2_SERVER_REPOSITORY=product-apim +ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION} +ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER} +ARG WSO2_SERVER_DIST_URL=https://github.com/wso2/${WSO2_SERVER_REPOSITORY}/releases/download/v${WSO2_SERVER_VERSION}/${WSO2_SERVER}.zip +# 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 + +# 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 \ + libxml2-utils \ + netcat \ + unzip \ + wget \ + && rm -rf /var/lib/apt/lists/* +# add the WSO2 product distribution to user's home directory +RUN \ + wget -O ${WSO2_SERVER}.zip "${WSO2_SERVER_DIST_URL}" \ + && unzip -d ${USER_HOME} ${WSO2_SERVER}.zip \ + && chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \ + && mkdir ${USER_HOME}/wso2-tmp \ + && bash -c 'mkdir -p ${USER_HOME}/solr/{indexed-data,database}' \ + && chown wso2carbon:wso2 -R ${USER_HOME}/solr \ + && cp -r ${WSO2_SERVER_HOME}/repository/deployment/server/synapse-configs ${USER_HOME}/wso2-tmp \ + && cp -r ${WSO2_SERVER_HOME}/repository/deployment/server/executionplans ${USER_HOME}/wso2-tmp \ + && rm -f ${WSO2_SERVER}.zip + +# set the user and work directory +USER ${USER_ID} +WORKDIR ${USER_HOME} + +# set environment variables +ENV WORKING_DIRECTORY=${USER_HOME} \ + WSO2_SERVER_HOME=${WSO2_SERVER_HOME} + +# expose ports +EXPOSE 9763 9443 9999 11111 8280 8243 5672 9711 9611 9099 + +# initiate container and start WSO2 Carbon server +ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"] diff --git a/dockerfiles/jdk8/ubuntu/apim/README.md b/dockerfiles/jdk8/ubuntu/apim/README.md new file mode 100755 index 00000000..3490362f --- /dev/null +++ b/dockerfiles/jdk8/ubuntu/apim/README.md @@ -0,0 +1,74 @@ +# Dockerfile for WSO2 API Manager # + +This section defines the step-by-step instructions to build an [Ubuntu](https://hub.docker.com/_/ubuntu/) Linux based Docker image for WSO2 API Manager 4.0.0. + +## Prerequisites + +* [Docker](https://www.docker.com/get-docker) v17.09.0 or above +* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) client + +## How to build an image and run + +##### 1. Checkout this repository into your local machine using the following Git client command. + +``` +git clone https://github.com/wso2/docker-apim.git +``` + +> The local copy of the `dockerfiles/ubuntu/apim` directory will be referred to as `AM_DOCKERFILE_HOME` from this point onwards. + +##### 2. Build the Docker image. + +- Navigate to `` directory.
+ Execute `docker build` command as shown below. + + `docker build -t wso2am:4.0.0 .` + +> By default, the Docker image will prepackage the General Availability (GA) release version of the relevant WSO2 product. + +##### 3. Running the Docker image. + +- `docker run -it -p 9443:9443 wso2am:4.0.0` + +> Here, only port 9443 (HTTPS servlet transport) has been mapped to a Docker host port. +You may map other container service ports, which have been exposed to Docker host ports, as desired. + +##### 4. Accessing management console. + +- To access the management console, use the docker host IP and port 9443. + + `https://:9443/carbon` + +> In here, refers to hostname or IP of the host machine on top of which containers are spawned. + +## How to update configurations + +Configurations would lie on the Docker host machine and they can be volume mounted to the container.
+As an example, steps required to change the port offset using `deployment.toml` is as follows: + +##### 1. Stop the API Manager container if it's already running. + +In WSO2 API Manager version 4.0.0 product distribution, `deployment.toml` configuration file
+can be found at `/repository/conf`. Copy the file to some suitable location of the host machine,
+referred to as `/deployment.toml` and change the offset value (`[server]->offset`) to 1. + +##### 2. Grant read permission to `other` users for `/deployment.toml`. + +``` +chmod o+r /deployment.toml +``` + +##### 3. Run the image by mounting the file to container as follows: + +``` +docker run \ +-p 9444:9444 \ +--volume /deployment.toml:/deployment.toml \ +wso2am:4.0.0 +``` + +> In here, refers to /home/wso2carbon/wso2am-4.0.0/repository/conf folder of the container. + +## Docker command usage references + +* [Docker build command reference](https://docs.docker.com/engine/reference/commandline/build/) +* [Docker run command reference](https://docs.docker.com/engine/reference/run/) +* [Dockerfile reference](https://docs.docker.com/engine/reference/builder/) diff --git a/dockerfiles/jdk8/ubuntu/apim/docker-entrypoint.sh b/dockerfiles/jdk8/ubuntu/apim/docker-entrypoint.sh new file mode 100755 index 00000000..2bf2dcfc --- /dev/null +++ b/dockerfiles/jdk8/ubuntu/apim/docker-entrypoint.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# ------------------------------------------------------------------------ +# Copyright 2018 WSO2, Inc. (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 +# home of the directories to be artifact synced within the WSO2 product home +deployment_volume=${WSO2_SERVER_HOME}/repository/deployment/server +# home of the directories with preserved, default deployment artifacts +original_deployment_artifacts=${WORKING_DIRECTORY}/wso2-tmp + +# 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 + +# shared artifact directories +directories=("executionplans" "synapse-configs") +# if the original directory locations of artifacts to be synced between nodes are empty, +# copy the preserved, default content of these folders to these original locations +for shared_directory in ${directories[@]}; do + if test -d ${original_deployment_artifacts}/${shared_directory}; + then + if [[ -z "$(ls -A ${deployment_volume}/${shared_directory})" ]]; then + if ! cp -R ${original_deployment_artifacts}/${shared_directory}/* ${deployment_volume}/${shared_directory}; + then + echo "Failed to copy the preserved, default artifacts to original location (${deployment_volume}/${shared_directory})" + exit 1 + fi + echo "Successfully copied the preserved, default artifacts to original location (${deployment_volume}/${shared_directory})" + fi + fi +done + +# optimize WSO2 Carbon Server, if the profile name is defined as an environment variable +if [[ ! -z "${PROFILE_NAME}" ]] +then + echo "Optimizing WSO2 Carbon Server" >&2 + sh ${WSO2_SERVER_HOME}/bin/profileSetup.sh -Dprofile=${PROFILE_NAME} +fi + +# 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 +echo "Start WSO2 Carbon server" >&2 +if [[ -z "${PROFILE_NAME}" ]] +then + # start the server with the provided startup arguments + sh ${WSO2_SERVER_HOME}/bin/api-manager.sh "$@" +else + # start the server with the specified profile and provided startup arguments + sh ${WSO2_SERVER_HOME}/bin/api-manager.sh -Dprofile=${PROFILE_NAME} "$@" +fi From da4c0dd3ba7c631eeae109e28673d082c83a5007 Mon Sep 17 00:00:00 2001 From: Tharika Madurapperuma Date: Sat, 5 Feb 2022 09:38:49 +0530 Subject: [PATCH 2/4] Change license headers --- dockerfiles/jdk8/alpine/apim/Dockerfile | 2 +- dockerfiles/jdk8/alpine/apim/docker-entrypoint.sh | 2 +- dockerfiles/jdk8/centos/apim/Dockerfile | 2 +- dockerfiles/jdk8/centos/apim/docker-entrypoint.sh | 2 +- dockerfiles/jdk8/ubuntu/apim/Dockerfile | 2 +- dockerfiles/jdk8/ubuntu/apim/docker-entrypoint.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dockerfiles/jdk8/alpine/apim/Dockerfile b/dockerfiles/jdk8/alpine/apim/Dockerfile index d7669c69..caa3f077 100755 --- a/dockerfiles/jdk8/alpine/apim/Dockerfile +++ b/dockerfiles/jdk8/alpine/apim/Dockerfile @@ -1,6 +1,6 @@ # ------------------------------------------------------------------------ # -# Copyright 2018 WSO2, Inc. (http://wso2.com) +# Copyright 2022 WSO2, Inc. (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. diff --git a/dockerfiles/jdk8/alpine/apim/docker-entrypoint.sh b/dockerfiles/jdk8/alpine/apim/docker-entrypoint.sh index 2bf2dcfc..1886e3fe 100755 --- a/dockerfiles/jdk8/alpine/apim/docker-entrypoint.sh +++ b/dockerfiles/jdk8/alpine/apim/docker-entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash # ------------------------------------------------------------------------ -# Copyright 2018 WSO2, Inc. (http://wso2.com) +# Copyright 2022 WSO2, Inc. (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. diff --git a/dockerfiles/jdk8/centos/apim/Dockerfile b/dockerfiles/jdk8/centos/apim/Dockerfile index b390dc9a..351c6b34 100755 --- a/dockerfiles/jdk8/centos/apim/Dockerfile +++ b/dockerfiles/jdk8/centos/apim/Dockerfile @@ -1,6 +1,6 @@ # ------------------------------------------------------------------------ # -# Copyright 2018 WSO2, Inc. (http://wso2.com) +# Copyright 2022 WSO2, Inc. (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. diff --git a/dockerfiles/jdk8/centos/apim/docker-entrypoint.sh b/dockerfiles/jdk8/centos/apim/docker-entrypoint.sh index 2bf2dcfc..1886e3fe 100755 --- a/dockerfiles/jdk8/centos/apim/docker-entrypoint.sh +++ b/dockerfiles/jdk8/centos/apim/docker-entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash # ------------------------------------------------------------------------ -# Copyright 2018 WSO2, Inc. (http://wso2.com) +# Copyright 2022 WSO2, Inc. (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. diff --git a/dockerfiles/jdk8/ubuntu/apim/Dockerfile b/dockerfiles/jdk8/ubuntu/apim/Dockerfile index 7ddae151..c7f70119 100755 --- a/dockerfiles/jdk8/ubuntu/apim/Dockerfile +++ b/dockerfiles/jdk8/ubuntu/apim/Dockerfile @@ -1,6 +1,6 @@ # ------------------------------------------------------------------------ # -# Copyright 2017 WSO2, Inc. (http://wso2.com) +# Copyright 2022 WSO2, Inc. (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. diff --git a/dockerfiles/jdk8/ubuntu/apim/docker-entrypoint.sh b/dockerfiles/jdk8/ubuntu/apim/docker-entrypoint.sh index 2bf2dcfc..1886e3fe 100755 --- a/dockerfiles/jdk8/ubuntu/apim/docker-entrypoint.sh +++ b/dockerfiles/jdk8/ubuntu/apim/docker-entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash # ------------------------------------------------------------------------ -# Copyright 2018 WSO2, Inc. (http://wso2.com) +# Copyright 2022 WSO2, Inc. (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. From ac34d36352d204162f4afcd18545afc334e66594 Mon Sep 17 00:00:00 2001 From: Tharika Madurapperuma Date: Sat, 5 Feb 2022 09:43:21 +0530 Subject: [PATCH 3/4] Update Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbc5498b..599caff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to Docker and Docker Compose resources for WSO2 API Manageme The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [v4.0.0.2] - 2022-02-05 +## [v4.0.0.3] - 2022-02-07 ### Changed - Change folder structure of dockerfile locations and introduced separate images for jdk8 and jdk11 (refer to [issue](https://github.com/wso2/product-apim/issues/12223) From 77b3a4c4d730a690cd75ab33d0cdc6ccc1e58e19 Mon Sep 17 00:00:00 2001 From: Tharika Madurapperuma Date: Mon, 7 Feb 2022 10:58:57 +0530 Subject: [PATCH 4/4] Update README.md --- dockerfiles/jdk8/alpine/apim/README.md | 6 +++--- dockerfiles/jdk8/centos/apim/README.md | 6 +++--- dockerfiles/jdk8/ubuntu/apim/README.md | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dockerfiles/jdk8/alpine/apim/README.md b/dockerfiles/jdk8/alpine/apim/README.md index b489f119..22e18218 100755 --- a/dockerfiles/jdk8/alpine/apim/README.md +++ b/dockerfiles/jdk8/alpine/apim/README.md @@ -21,13 +21,13 @@ git clone https://github.com/wso2/docker-apim.git - Navigate to `` directory.
Execute `docker build` command as shown below. - + `docker build -t wso2am:4.0.0-alpine .` + + `docker build -t wso2am:4.0.0-alpine-jdk8 .` > By default, the Docker image will prepackage the General Availability (GA) release version of the relevant WSO2 product. ##### 3. Running the Docker image. -- `docker run -it -p 9443:9443 wso2am:4.0.0-alpine` +- `docker run -it -p 9443:9443 wso2am:4.0.0-alpine-jdk8` > Here, only port 9443 (HTTPS servlet transport) has been mapped to a Docker host port. You may map other container service ports, which have been exposed to Docker host ports, as desired. @@ -62,7 +62,7 @@ chmod o+r /deployment.toml docker run \ -p 9444:9444 \ --volume /deployment.toml:/deployment.toml \ -wso2am:4.0.0-alpine +wso2am:4.0.0-alpine-jdk8 ``` > In here, refers to /home/wso2carbon/wso2am-4.0.0/repository/conf folder of the container. diff --git a/dockerfiles/jdk8/centos/apim/README.md b/dockerfiles/jdk8/centos/apim/README.md index ba603475..c8e1c8b7 100755 --- a/dockerfiles/jdk8/centos/apim/README.md +++ b/dockerfiles/jdk8/centos/apim/README.md @@ -22,13 +22,13 @@ git clone https://github.com/wso2/docker-apim.git - Navigate to `` directory.
Execute `docker build` command as shown below. - + `docker build -t wso2am:4.0.0-centos .` + + `docker build -t wso2am:4.0.0-centos-jdk8 .` > By default, the Docker image will prepackage the General Availability (GA) release version of the relevant WSO2 product. ##### 3. Running the Docker image. -- `docker run -it -p 9443:9443 wso2am:4.0.0-centos` +- `docker run -it -p 9443:9443 wso2am:4.0.0-centos-jdk8` > Here, only port 9443 (HTTPS servlet transport) has been mapped to a Docker host port. You may map other container service ports, which have been exposed to Docker host ports, as desired. @@ -63,7 +63,7 @@ chmod o+r /deployment.toml docker run \ -p 9444:9444 \ --volume /deployment.toml:/deployment.toml \ -wso2am:4.0.0-centos +wso2am:4.0.0-centos-jdk8 ``` > In here, refers to /home/wso2carbon/wso2am-4.0.0/repository/conf folder of the container. diff --git a/dockerfiles/jdk8/ubuntu/apim/README.md b/dockerfiles/jdk8/ubuntu/apim/README.md index 3490362f..899210e8 100755 --- a/dockerfiles/jdk8/ubuntu/apim/README.md +++ b/dockerfiles/jdk8/ubuntu/apim/README.md @@ -21,13 +21,13 @@ git clone https://github.com/wso2/docker-apim.git - Navigate to `` directory.
Execute `docker build` command as shown below. - + `docker build -t wso2am:4.0.0 .` + + `docker build -t wso2am:4.0.0-jdk8 .` > By default, the Docker image will prepackage the General Availability (GA) release version of the relevant WSO2 product. ##### 3. Running the Docker image. -- `docker run -it -p 9443:9443 wso2am:4.0.0` +- `docker run -it -p 9443:9443 wso2am:4.0.0-jdk8` > Here, only port 9443 (HTTPS servlet transport) has been mapped to a Docker host port. You may map other container service ports, which have been exposed to Docker host ports, as desired. @@ -62,7 +62,7 @@ chmod o+r /deployment.toml docker run \ -p 9444:9444 \ --volume /deployment.toml:/deployment.toml \ -wso2am:4.0.0 +wso2am:4.0.0-jdk8 ``` > In here, refers to /home/wso2carbon/wso2am-4.0.0/repository/conf folder of the container.