Skip to content

Commit

Permalink
Merge pull request #103 from chirangaalwis/docker-ei-v6.4.x-refinements
Browse files Browse the repository at this point in the history
Optimize WSO2 Enterprise Integrator product Docker resources and use AdoptOpenJDK 8
  • Loading branch information
DilanUA authored Jan 11, 2019
2 parents bf73b2c + 1f0c65a commit 8e274b3
Show file tree
Hide file tree
Showing 82 changed files with 2,585 additions and 754 deletions.
138 changes: 0 additions & 138 deletions dockerfiles/alpine/README.md

This file was deleted.

110 changes: 110 additions & 0 deletions dockerfiles/alpine/analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# 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 multiple profiles
provided by WSO2 Enterprise Integrator 6.4.0, namely:<br>

1. Dashboard
2. Worker

## 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. Add Analytics profile distribution and MySQL connector to `<ANALYTICS_DOCKERFILE_HOME>/base/files`.

- Download [WSO2 Enterprise Integrator 6.4.0 distribution](https://wso2.com/integration/) distribution.
Extract the product distribution and execute the `<EI_HOME>/bin/profile-creator.sh` to generate the Micro Integrator
profile distribution.

```
./<EI_HOME>/bin/profile-creator.sh
```

Extract the generated profile distribution to `<ANALYTICS_DOCKERFILE_HOME>/base/files`.

- Download [MySQL Connector/J](https://downloads.mysql.com/archives/c-j)
and copy that to `<ANALYTICS_DOCKERFILE_HOME>/base/files`.
- Once all of these are in place, it should look as follows:

```bash
<ANALYTICS_DOCKERFILE_HOME>/base/files/wso2ei-6.4.0/
<ANALYTICS_DOCKERFILE_HOME>/base/files/mysql-connector-java-<version>-bin.jar
```

>Please refer to [WSO2 Update Manager documentation]( https://docs.wso2.com/display/WUM300/WSO2+Update+Manager)
in order to obtain latest bug fixes and updates for the product.

##### 3. Build the base Docker image.

- For base, navigate to `<ANALYTICS_DOCKERFILE_HOME>/base` directory. <br>
Execute `docker build` command as shown below.
+ `docker build -t wso2ei-analytics-base:6.4.0-alpine .`

##### 4. Build Docker images specific to each profile.

- For dashboard, navigate to `<ANALYTICS_DOCKERFILE_HOME>/dashboard` directory. <br>
Execute `docker build` command as shown below.
+ `docker build -t wso2ei-analytics-dashboard:6.4.0-alpine .`
- For worker, navigate to `<ANALYTICS_DOCKERFILE_HOME>/worker` directory. <br>
Execute `docker build` command as shown below.
+ `docker build -t wso2ei-analytics-worker:6.4.0-alpine .`

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

- For dashboard,
+ `docker run -p 9713:9713 -p 9643:9643 ...all-port-mappings-here... wso2ei-analytics-dashboard:6.4.0-alpine`
- For worker,
+ `docker run -p 9444:9444 ...all-port-mappings-here... wso2ei-analytics-worker:6.4.0-alpine`

##### 6. Accessing the Dashboard portal.

- For Analytics Dashboard,
+ Business Rules:<br>
`https://<DOCKER_HOST>:9643/business-rules`
+ Portal:<br>
`https://<DOCKER_HOST>:9643/portal`
+ Monitoring:<br>
`https://<DOCKER_HOST>:9643/monitoring`

>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 `deployment.yaml` is as follows.

##### 1. Stop the Enterprise Integrator Analytics container if it's already running.
In WSO2 Enterprise Integrator 6.4.0 product distribution, `deployment.yaml` configuration file <br>
can be found at `<DISTRIBUTION_HOME>/wso2/analytics/conf/worker`. Copy the file to some suitable location of the host machine, <br>
referred to as `<SOURCE_CONFIGS>/deployment.yaml` and change the offset value under ports to 2.

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

##### 3. Run the image by mounting the file to container as follows.
```
docker run
-p 9444:9444
--volume <SOURCE_CONFIGS>/deployment.yaml:<TARGET_CONFIGS>/deployment.yaml
wso2ei-analytics-worker:6.4.0-alpine
```

>In here, <TARGET_CONFIGS> refers to /home/wso2carbon/wso2ei-6.4.0/wso2/analytics/conf/worker 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/)
67 changes: 67 additions & 0 deletions dockerfiles/alpine/analytics/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# ------------------------------------------------------------------------
#
# 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:jdk8u192-b12-alpine
MAINTAINER WSO2 Docker Maintainers "dev@wso2.org"

# set user configurations
ARG USER=wso2carbon
ARG USER_ID=802
ARG USER_GROUP=wso2
ARG USER_GROUP_ID=802
ARG USER_HOME=/home/${USER}
# set dependant files directory
ARG FILES=./files
# set wso2 product configurations
ARG WSO2_SERVER=wso2ei
ARG WSO2_SERVER_VERSION=6.4.0
ARG WSO2_SERVER_PACK=${WSO2_SERVER}-${WSO2_SERVER_VERSION}
ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER_PACK}
ENV ENV=${USER_HOME}"/.ashrc"

# set WSO2 EULA
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"

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

# create a user group and a user
RUN addgroup -g ${USER_GROUP_ID} ${USER_GROUP}; \
adduser -u ${USER_ID} -D -g '' -h ${USER_HOME} -G ${USER_GROUP} ${USER} ;

# MOTD login message
RUN echo $MOTD > "$ENV"

# copy wso2 product distribution to user's home directory and copy mysql connector jar to product distribution
COPY --chown=wso2carbon:wso2 ${FILES}/${WSO2_SERVER_PACK} ${WSO2_SERVER_HOME}
COPY --chown=wso2carbon:wso2 ${FILES}/mysql-connector-java-*-bin.jar ${WSO2_SERVER_HOME}/wso2/analytics/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}
6 changes: 2 additions & 4 deletions dockerfiles/alpine/analytics/dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
# ------------------------------------------------------------------------

# set to product base image
FROM wso2ei-base:6.4.0-alpine
ARG FILES=./files
FROM wso2ei-analytics-base:6.4.0-alpine

# copy entrypoint bash script to user home
COPY --chown=wso2carbon:wso2 init.sh ${WORKING_DIRECTORY}/
COPY --chown=wso2carbon:wso2 ${FILES}/mysql-connector-java-*-bin.jar ${WSO2_SERVER_HOME}/wso2/analytics/lib/

# expose analytics ports
EXPOSE 9444 7612 7712 9161
EXPOSE 9713 9643 9613 7713 7613

# set entrypoint to init script
ENTRYPOINT ["/home/wso2carbon/init.sh"]
3 changes: 2 additions & 1 deletion dockerfiles/alpine/analytics/dashboard/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License
# ------------------------------------------------------------------------

set -e

# volume mounts
Expand Down Expand Up @@ -65,4 +66,4 @@ test -d ${config_volume}/ && cp -RL ${config_volume}/* ${WSO2_SERVER_HOME}/
test -d ${artifact_volume}/ && cp -RL ${artifact_volume}/* ${WSO2_SERVER_HOME}/

# start WSO2 Carbon server
sh ${WSO2_SERVER_HOME}/bin/analytics-dashboard.sh
sh ${WSO2_SERVER_HOME}/bin/analytics-dashboard.sh "$@"
6 changes: 2 additions & 4 deletions dockerfiles/alpine/analytics/worker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
# ------------------------------------------------------------------------

# set to product base image
FROM wso2ei-base:6.4.0-alpine
ARG FILES=./files
FROM wso2ei-analytics-base:6.4.0-alpine

# copy entrypoint bash script to user home
COPY --chown=wso2carbon:wso2 init.sh ${WORKING_DIRECTORY}/
COPY --chown=wso2carbon:wso2 ${FILES}/mysql-connector-java-*-bin.jar ${WSO2_SERVER_HOME}/wso2/analytics/lib/

# expose analytics ports
EXPOSE 9444 7612 7712 9161
EXPOSE 9091 9444 9712 9612 7712 7612 7070 7443

# set entrypoint to init script
ENTRYPOINT ["/home/wso2carbon/init.sh"]
3 changes: 2 additions & 1 deletion dockerfiles/alpine/analytics/worker/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License
# ------------------------------------------------------------------------

set -e

# volume mounts
Expand Down Expand Up @@ -65,4 +66,4 @@ test -d ${config_volume}/ && cp -RL ${config_volume}/* ${WSO2_SERVER_HOME}/
test -d ${artifact_volume}/ && cp -RL ${artifact_volume}/* ${WSO2_SERVER_HOME}/

# start WSO2 Carbon server
sh ${WSO2_SERVER_HOME}/bin/analytics-worker.sh
sh ${WSO2_SERVER_HOME}/bin/analytics-worker.sh "$@"
Loading

0 comments on commit 8e274b3

Please sign in to comment.