Skip to content

Commit

Permalink
Add Dockerfiles, docker-entrypoint.sh and readme files to EI-6.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sajinieKavindya authored and chirangaalwis committed Aug 27, 2021
1 parent a3de5fa commit d71503a
Show file tree
Hide file tree
Showing 50 changed files with 2,877 additions and 607 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project `6.2.x` per each release will be documented

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [v6.2.0.9] - 2021-08-26

### Added
- Add per profile Docker resources of WSO2 Enterprise Integrator v6.2.x for Alpine, CentOS, Ubuntu

### Changed
- Update AdoptOpenJDK version to adoptopenjdk/openjdk8:jdk8u292-b10-alpine in all Alpine based images
- Update K8s Membership scheme version to 1.0.7

## [v6.2.0.8] - 2020-11-25

### Added
Expand Down
97 changes: 97 additions & 0 deletions dockerfiles/alpine/analytics/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# ------------------------------------------------------------------------
#
# Copyright 2021 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 <dev@wso2.org>" \
com.wso2.docker.source="https://github.com/wso2/docker-ei/releases/tag/v6.2.0.9"

# 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=wso2ei
ARG WSO2_SERVER_VERSION=6.2.0
ARG WSO2_SERVER_PROFILE_NAME=analytics
ARG WSO2_SERVER_PROFILE_OPTIMIZER_NUMBER=2
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/product-ei/releases/download/v${WSO2_SERVER_VERSION}/${WSO2_SERVER}.zip
# build arguments for external artifacts
ARG DNS_JAVA_VERSION=2.1.8
ARG K8S_MEMBERSHIP_SCHEME_VERSION=1.0.7
ARG MYSQL_CONNECTOR_VERSION=5.1.49
# 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 \
curl \
netcat-openbsd \
zip
# add the WSO2 product distribution to user's home directory
RUN \
wget --no-check-certificate -O ${WSO2_SERVER}.zip "${WSO2_SERVER_DIST_URL}" \
&& unzip -d ${USER_HOME} ${WSO2_SERVER}.zip \
&& rm -f ${WSO2_SERVER}.zip \
&& echo "${WSO2_SERVER_PROFILE_OPTIMIZER_NUMBER}" | bash ${WSO2_SERVER_HOME}/bin/profile-creator.sh \
&& rm -rf ${WSO2_SERVER_HOME} \
&& unzip -d ${USER_HOME} ${WSO2_SERVER_HOME}_${WSO2_SERVER_PROFILE_NAME}.zip \
&& chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \
&& rm -f ${WSO2_SERVER_HOME}_${WSO2_SERVER_PROFILE_NAME}.zip

# add MySQL JDBC connector to server home as a third party library
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}/lib/

# 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}/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}/dropins

# 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 analytics ports
EXPOSE 9444 9612 9712 7612 7712

# initiate container and start WSO2 Carbon server
ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"]
67 changes: 67 additions & 0 deletions dockerfiles/alpine/analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Dockerfile for WSO2 Enterprise Integrator Analytics #

This section defines the step-by-step instructions to build [Alpine](https://hub.docker.com/_/alpine/) Linux based Docker images for Analytics profile
in WSO2 Enterprise Integrator 6.2.0.

## Prerequisites

* [Docker](https://www.docker.com/get-docker) v17.09.0 or above

## How to build an image and run
##### 1. Checkout this repository into your local machine using the following Git command.

```
git clone https://github.com/wso2/docker-ei.git
```

>The local copy of the `dockerfile/alpine/analytics` directory will be referred to as `ANALYTICS_DOCKERFILE_HOME` from this point onwards.
##### 2. Build Docker images specific to each profile.

- Navigate to `<ANALYTICS_DOCKERFILE_HOME>` directory. <br>
Execute `docker build` command as shown below.
+ `docker build -t wso2ei-analytics:6.2.0-alpine .`
- If you want to use your own distribution, you may build the image by executing the following command,
+ eg:- Hosted locally:` docker build --build-arg WSO2_SERVER_DIST_URL=http://172.17.0.1:8000/wso2ei-6.2.0.zip -t wso2ei-<PROFILE>:6.2.0-alpine .`

##### 3. Running Docker images specific to each profile.

- `docker run -p 9444:9444 -p 9612:9612 ...all-port-mappings-here... wso2ei-analytics:6.2.0-alpine`

##### 4. Accessing the Dashboard portal.

- To access the management console, use the docker host IP and port 9446.
+ `https:<DOCKER_HOST>:9444/carbon`

>In here, <DOCKER_HOST> 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. <br>
As an example, steps required to change the port offset using `carbon.xml` is as follows.

##### 1. Stop the Broker profile container if it's already running.
In Broker profile product distribution, `carbon.xml` configuration file can be found at `<DISTRIBUTION_HOME>/wso2/analytics/conf`.
Copy the file to some suitable location of the host machine, referred to as `<SOURCE_CONFIGS>/carbon.xml` and
increase the offset value under ports by 1.

##### 2. Grant read permission to `other` users for `<SOURCE_CONFIGS>/carbon.xml`
```
chmod o+r <SOURCE_CONFIGS>/carbon.xml
```

##### 3. Run the image by mounting the file to container as follows.
```
docker run \
-p 9445:9445 \
--volume <SOURCE_CONFIGS>/carbon.xml:<TARGET_CONFIGS>/carbon.xml \
wso2ei-analytics:6.2.0-alpine
```

>In here, <TARGET_CONFIGS> refers to /home/wso2carbon/wso2ei-6.2.0/wso2/analytics/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/)
36 changes: 36 additions & 0 deletions dockerfiles/alpine/analytics/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh
# ------------------------------------------------------------------------
# Copyright 2021 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

# 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 ${artifact_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/analytics.sh "$@"
103 changes: 103 additions & 0 deletions dockerfiles/alpine/broker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# ------------------------------------------------------------------------
#
# Copyright 2021 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
#
# ------------------------------------------------------------------------

FROM adoptopenjdk/openjdk8:jdk8u292-b10-alpine
LABEL maintainer="WSO2 Docker Maintainers <dev@wso2.org>" \
com.wso2.docker.source="https://github.com/wso2/docker-ei/releases/tag/v6.2.0.9"

# 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=wso2ei
ARG WSO2_SERVER_VERSION=6.2.0
ARG WSO2_SERVER_PROFILE_NAME=broker
ARG WSO2_SERVER_PROFILE_OPTIMIZER_NUMBER=4
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/product-ei/releases/download/v${WSO2_SERVER_VERSION}/${WSO2_SERVER}.zip
# build arguments for external artifacts
ARG DNS_JAVA_VERSION=2.1.8
ARG K8S_MEMBERSHIP_SCHEME_VERSION=1.0.7
ARG MYSQL_CONNECTOR_VERSION=5.1.49
# 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"

# install required packages
RUN apk add --update --no-cache \
bash \
zip \
curl \
netcat-openbsd && \
rm -rf /var/cache/apk/*

# 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 entrypoint bash script to user home
COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/

# 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

RUN \
wget --no-check-certificate -O ${WSO2_SERVER}.zip "${WSO2_SERVER_DIST_URL}" \
&& unzip -d ${USER_HOME} ${WSO2_SERVER}.zip \
&& rm -f ${WSO2_SERVER}.zip \
&& echo "${WSO2_SERVER_PROFILE_OPTIMIZER_NUMBER}" | bash ${WSO2_SERVER_HOME}/bin/profile-creator.sh \
&& rm -rf ${WSO2_SERVER_HOME} \
&& unzip -d ${USER_HOME} ${WSO2_SERVER_HOME}_${WSO2_SERVER_PROFILE_NAME}.zip \
&& chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \
&& rm -f ${WSO2_SERVER_HOME}_${WSO2_SERVER_PROFILE_NAME}.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}/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}/dropins
# add MySQL JDBC connector to server home as a third party library
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}/lib/

# set the user and work directory
USER ${USER_ID}
WORKDIR ${USER_HOME}

# set environment variables
ENV WSO2_SERVER_HOME=${WSO2_SERVER_HOME} \
WORKING_DIRECTORY=${USER_HOME} \
JAVA_OPTS="-Djava.util.prefs.systemRoot=${USER_HOME}/.java -Djava.util.prefs.userRoot=${USER_HOME}/.java/.userPrefs"

# expose broker ports
EXPOSE 9446 9766 5675 8675 1886 8836 7614 4000

# initiate container and start WSO2 Carbon server
ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"]
66 changes: 66 additions & 0 deletions dockerfiles/alpine/broker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Dockerfile for Broker profile of WSO2 Enterprise Integrator #
This section defines the step-by-step instructions to build an [Alpine](https://hub.docker.com/_/alpine/) Linux based Docker image
Broker profile for WSO2 Enterprise Integrator 6.2.0.

## Prerequisites

* [Docker](https://www.docker.com/get-docker) v17.09.0 or above


## How to build an image and run
##### 1. Checkout this repository into your local machine using the following Git command.
```
git clone https://github.com/wso2/docker-ei.git
```

>The local copy of the `dockerfiles/alpine/broker` directory will be referred to as `BROKER_DOCKERFILE_HOME` from this point onwards.
##### 2. Build the Docker image.
- Navigate to `<BROKER_DOCKERFILE_HOME>` directory. <br>
Execute `docker build` command as shown below.
+ `docker build -t wso2ei-broker:6.2.0-alpine .`
- If you want to use your own distribution, you may build the image by executing the following command,
+ eg:- Hosted locally:` docker build --build-arg WSO2_SERVER_DIST_URL=http://172.17.0.1:8000/wso2ei-6.2.0.zip -t wso2ei-broker:6.2.0-alpine .`

##### 3. Running the Docker image.
- `docker run -p 9446:9446 ...all-port-mappings-here... wso2ei-broker:6.2.0-alpine`
>Here, only port 9446 (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 9446.
+ `https:<DOCKER_HOST>:9446/carbon`

>In here, <DOCKER_HOST> 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. <br>
As an example, steps required to change the port offset using `carbon.xml` is as follows.

##### 1. Stop the Broker profile container if it's already running.
In Broker profile product distribution, `carbon.xml` configuration file can be found at `<DISTRIBUTION_HOME>/wso2/broker/conf`.
Copy the file to some suitable location of the host machine, referred to as `<SOURCE_CONFIGS>/carbon.xml` and increase
the offset value under ports by 1.

##### 2. Grant read permission to `other` users for `<SOURCE_CONFIGS>/carbon.xml`
```
chmod o+r <SOURCE_CONFIGS>/carbon.xml
```

##### 3. Run the image by mounting the file to container as follows.
```
docker run \
-p 9447:9447 \
--volume <SOURCE_CONFIGS>/carbon.xml:<TARGET_CONFIGS>/carbon.xml \
wso2ei-broker:6.2.0-alpine
```

>In here, <TARGET_CONFIGS> refers to /home/wso2carbon/wso2ei-6.2.0/wso2/broker/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/)
Loading

0 comments on commit d71503a

Please sign in to comment.