Skip to content

Commit

Permalink
Merge pull request #157 from Chathuratharushka/multiple-base-product-…
Browse files Browse the repository at this point in the history
…versions-uk

[Docker][OB3][UK] - change the UK toolkit dockerfiles to use them with multiple base product versions.
  • Loading branch information
DivyaPremanantha authored May 23, 2023
2 parents c09d830 + 9b35ce6 commit b9b60d6
Show file tree
Hide file tree
Showing 12 changed files with 625 additions and 33 deletions.
117 changes: 117 additions & 0 deletions dockerfiles/alpine/obam-uk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# ----------------------------------------------------------------------------------------
#
# Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
#
# This software is the property of WSO2 LLC. and its suppliers, if any.
# Dissemination of any information or reproduction of any material contained
# herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
# You may not alter or remove any copyright or other notice from copies of this content.
#
# ----------------------------------------------------------------------------------------

ARG BASE_DOCKER_IMAGE_REGISTRY="docker.wso2.com"
ARG BASE_PRODUCT_VERSION
ARG ACCELERATOR_PRODUCT_VERSION=3.0.0.0-am${BASE_PRODUCT_VERSION}.0-alpine
# set base Docker image to WSO2 Open Banking API Manager Alpine Docker image
FROM ${BASE_DOCKER_IMAGE_REGISTRY}/wso2-obam:${ACCELERATOR_PRODUCT_VERSION}
LABEL maintainer="WSO2 Docker Maintainers <[email protected]>" \
com.wso2.docker.source="https://github.com/wso2/docker-open-banking/releases/tag/v3.0.0.10"

# 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
# declaring again BASE_PRODUCT_VERSION ARG to use in build stage
ARG BASE_PRODUCT_VERSION
ARG WSO2_OB_TOOLKIT_NAME=wso2-obam-toolkit-uk
ARG WSO2_OB_TOOLKIT_VERSION=1.0.0
ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${BASE_PRODUCT_VERSION}
ARG WSO2_OB_TOOLKIT=${WSO2_OB_TOOLKIT_NAME}-${WSO2_OB_TOOLKIT_VERSION}
ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER}
ARG WSO2_OB_TOOLKIT_DIR=${WSO2_SERVER_HOME}/${WSO2_OB_TOOLKIT}
ARG WSO2_OB_TOOLKIT_DIST_URL
# build argument for MOTD
ARG MOTD='printf "\n\
Welcome to WSO2 Docker Resources \n\
--------------------------------- \n\
This Docker container comprises of the WSO2 Open Banking Solution, with its latest GA release \n\
which is under The WSO2 Commercial License 1.0. \n\
Read more about The WSO2 Commercial License, Version 1.0 here @ http://wso2.com/licenses \n"'
ENV ENV=${USER_HOME}"/.ashrc"

# configuration properties for deployment.toml file
# server hostnames
ARG IS_HOSTNAME=obiam
ARG APIM_HOSTNAME=obam
ARG BI_HOSTNAME=obbi
# databases related properties
ARG DB_TYPE=mysql
ARG DB_USER=root
ARG DB_PASS=root
ARG DB_HOST=mysql
ARG DB_DRIVER=com.mysql.jdbc.Driver
ARG DB_APIMGT=openbank_apimgtdb
ARG DB_USER_STORE=openbank_userdb
ARG DB_AM_CONFIG=openbank_am_configdb
ARG DB_GOV=openbank_govdb
ARG DB_IS_CONFIG=openbank_iskm_configdb
ARG DB_OPEN_BANKING_STORE=openbank_openbankingdb
ARG DB_OB_REPORTING=openbank_ob_reporting_statsdb
ARG DB_OB_REPORTING_SUMMARIZED=openbank_ob_reporting_summarizeddb

# change user to root for elevated permissions to override inherited non-root user
USER root

# add Open Banking artifacts to base product
RUN \
wget -O ${WSO2_OB_TOOLKIT}.zip "${WSO2_OB_TOOLKIT_DIST_URL}" \
&& unzip -d ${WSO2_SERVER_HOME}/ ${WSO2_OB_TOOLKIT}.zip \
&& rm -f ${WSO2_OB_TOOLKIT}.zip

# set configurations
# read deployment.toml file
ARG DEPLOYMENT_TOML_FILE=${WSO2_OB_TOOLKIT_DIR}/repository/resources/deployment.toml
RUN \
cp ${WSO2_OB_TOOLKIT_DIR}/repository/resources/wso2am-4.0.0-deployment-uk.toml ${DEPLOYMENT_TOML_FILE} \
# configure hostnames
&& sed -i -e 's|IS_HOSTNAME|'${IS_HOSTNAME}'|g' ${DEPLOYMENT_TOML_FILE} \
&& sed -i -e 's|APIM_HOSTNAME|'${APIM_HOSTNAME}'|g' ${DEPLOYMENT_TOML_FILE} \
&& sed -i -e 's|BI_HOSTNAME|'${BI_HOSTNAME}'|g' ${DEPLOYMENT_TOML_FILE} \
# configure datasources
&& sed -i -e 's|DB_APIMGT_URL|jdbc:mysql://'${DB_HOST}':3306/'${DB_APIMGT}'?autoReconnect=true\&amp;useSSL=false|g' ${DEPLOYMENT_TOML_FILE} \
&& sed -i -e 's|DB_AM_CONFIG_URL|jdbc:mysql://'${DB_HOST}':3306/'${DB_AM_CONFIG}'?autoReconnect=true\&amp;useSSL=false|g' ${DEPLOYMENT_TOML_FILE} \
&& sed -i -e 's|DB_GOV_URL|jdbc:mysql://'${DB_HOST}':3306/'${DB_GOV}'?autoReconnect=true\&amp;useSSL=false|g' ${DEPLOYMENT_TOML_FILE} \
&& sed -i -e 's|DB_USER_STORE_URL|jdbc:mysql://'${DB_HOST}':3306/'${DB_USER_STORE}'?autoReconnect=true\&amp;useSSL=false|g' ${DEPLOYMENT_TOML_FILE} \
&& sed -i -e 's|DB_USER|'${DB_USER}'|g' ${DEPLOYMENT_TOML_FILE} \
&& sed -i -e 's|DB_PASS|'${DB_PASS}'|g' ${DEPLOYMENT_TOML_FILE} \
&& sed -i -e 's|DB_DRIVER|'${DB_DRIVER}'|g' ${DEPLOYMENT_TOML_FILE} \
# copy deployment.toml file to repository/conf
&& cp ${DEPLOYMENT_TOML_FILE} ${WSO2_SERVER_HOME}/repository/conf/ \
&& rm ${DEPLOYMENT_TOML_FILE}

# copy the WSO2 OB APIM UK Toolkit artifacts on top of WSO2 APIM base product
# Remove default backend war
RUN \
rm ${WSO2_SERVER_HOME}/repository/deployment/server/webapps/api#openbanking#backend.war\
# copy toolkit artifacts
&& cp -r ${WSO2_OB_TOOLKIT_DIR}/carbon-home/* "${WSO2_SERVER_HOME}"

# change directory rights
RUN chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME}/

# set MOTD login message for open banking
RUN echo ${MOTD} > "${ENV}"

# set the non-root user
USER ${USER_ID}

# expose ports
EXPOSE 9443 8280 8243

# initiate container and start WSO2 Carbon server
ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"]
76 changes: 76 additions & 0 deletions dockerfiles/alpine/obam-uk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Dockerfile for WSO2 Open Banking API Manager UK Toolkit Module
This section defines the step-by-step instructions to build an [Alpine](https://hub.docker.com/_/alpine/) Linux based Docker image for WSO2 Open Banking API Manager UK Toolkit with WSO2 APIM 4.2.0.

## Prerequisites

* [Docker](https://www.docker.com/get-docker) v20.10.10 or above
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) client
* WSO2 Open Banking API Manager UK Toolkit Module pack

+ Host the downloaded artifacts locally or on a remote location.
> The hosted locations of artifacts will be passed as the build arguments when building the Docker image.<br>
> 1. **WSO2_OB_TOOLKIT_DIST_URL** - UK Toolkit location

## 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-open-banking.git
```

> The local copy of the `dockerfiles/alpine/obam-uk` directory will be referred to as `OBAM_UK_DOCKERFILE_HOME` from this point onwards.
##### 2. Build the Docker image.

- Navigate to `<OBAM_UK_DOCKERFILE_HOME>` directory. <br>
Execute `docker build` command as shown below.
+ `docker build --build-arg BASE_PRODUCT_VERSION=<APIM BASE PRODUCT VERSION> --build-arg WSO2_OB_TOOLKIT_DIST_URL=<URL_OF_THE_HOSTED_LOCATION/FILENAME> -t wso2-obam-uk:1.0.0-alpine .` <br>
> eg:- **Hosted locally**: `docker build --build-arg BASE_PRODUCT_VERSION=4.2.0 --build-arg WSO2_OB_TOOLKIT_DIST_URL=http://localhost:8000/wso2-obam-toolkit-uk-1.0.0.tar.gz -t wso2-obam-uk:1.0.0-alpine .` <br><br>
> eg:- **Hosted remotely**: `docker build --build-arg BASE_PRODUCT_VERSION=4.2.0 --build-arg WSO2_OB_TOOLKIT_DIST_URL=http://<public_ip:port>/wso2-obam-toolkit-uk-1.0.0.tar.gz -t wso2-obam-uk:1.0.0-alpine .`
##### 3. Running the Docker image.

- `docker run -it -p 9443:9443 -p 8243:8243 -p 8280:8280 wso2-obam-uk:1.0.0-alpine`

##### 4. Accessing management console.

- To access the management console, use the docker host IP and port 9443.
+ `https:<DOCKER_HOST>:9443/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 `deployment.toml` is as follows:

##### 1. Stop the API Manager container if it's already running.

In WSO2 Open Banking API Manager UK Toolkit 1.0.0 product distribution, `deployment.toml` configuration file <br>
can be found at `<DISTRIBUTION_HOME>/repository/conf`. Copy the file to some suitable location of the host machine, <br>
referred to as `<SOURCE_CONFIGS>/deployment.toml` and change the offset value under ports to 1.

##### 2. Grant read permission to `other` users for `<SOURCE_CONFIGS>/deployment.toml`.

```
chmod o+r <SOURCE_CONFIGS>/deployment.toml
```

##### 3. Run the image by mounting the file to container as follows:

```
docker run \
-p 9444:9444 \
--volume <SOURCE_CONFIGS>/deployment.toml:<TARGET_CONFIGS>/deployment.toml \
wso2-obam-uk:1.0.0-alpine
```

> In here, <TARGET_CONFIGS> 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/)
96 changes: 96 additions & 0 deletions dockerfiles/alpine/obbi-uk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# ----------------------------------------------------------------------------------------
#
# Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
#
# This software is the property of WSO2 LLC. and its suppliers, if any.
# Dissemination of any information or reproduction of any material contained
# herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
# You may not alter or remove any copyright or other notice from copies of this content.
#
# ----------------------------------------------------------------------------------------

ARG BASE_DOCKER_IMAGE_REGISTRY="docker.wso2.com"
ARG BASE_PRODUCT_VERSION
ARG ACCELERATOR_PRODUCT_VERSION=3.0.0.0-si${BASE_PRODUCT_VERSION}.0-alpine
# set base Docker image to WSO2 Open Banking Business Intelligence Alpine Docker image
FROM ${BASE_DOCKER_IMAGE_REGISTRY}/wso2-obbi:${ACCELERATOR_PRODUCT_VERSION}
LABEL maintainer="WSO2 Docker Maintainers <[email protected]>" \
com.wso2.docker.source="https://github.com/wso2/docker-open-banking/releases/tag/v3.0.0.10"

# 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=wso2si
# declaring again BASE_PRODUCT_VERSION ARG to use in build stage
ARG BASE_PRODUCT_VERSION
ARG WSO2_OB_TOOLKIT_NAME=wso2-obbi-toolkit-uk
ARG WSO2_OB_TOOLKIT_VERSION=1.0.0
ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${BASE_PRODUCT_VERSION}
ARG WSO2_OB_TOOLKIT=${WSO2_OB_TOOLKIT_NAME}-${WSO2_OB_TOOLKIT_VERSION}
ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER}
ARG WSO2_OB_TOOLKIT_DIR=${WSO2_SERVER_HOME}/${WSO2_OB_TOOLKIT}
ARG WSO2_OB_TOOLKIT_DIST_URL
# build argument for MOTD
ARG MOTD='printf "\n\
Welcome to WSO2 Docker Resources \n\
--------------------------------- \n\
This Docker container comprises of the WSO2 Open Banking Solution, with its latest GA release \n\
which is under The WSO2 Commercial License 1.0. \n\
Read more about The WSO2 Commercial License, Version 1.0 here @ http://wso2.com/licenses \n"'
ENV ENV=${USER_HOME}"/.ashrc"

# configuration properties for deployment.toml file
# server hostnames
ARG IS_HOSTNAME=obiam
ARG APIM_HOSTNAME=obam
ARG BI_HOSTNAME=obbi
# databases related properties
ARG DB_TYPE=mysql
ARG DB_USER=root
ARG DB_PASS=root
ARG DB_HOST=mysql
ARG DB_DRIVER=com.mysql.jdbc.Driver
ARG DB_APIMGT=openbank_apimgtdb
ARG DB_USER_STORE=openbank_userdb
ARG DB_AM_CONFIG=openbank_am_configdb
ARG DB_GOV=openbank_govdb
ARG DB_IS_CONFIG=openbank_iskm_configdb
ARG DB_OPEN_BANKING_STORE=openbank_openbankingdb
ARG DB_OB_REPORTING=openbank_ob_reporting_statsdb
ARG DB_OB_REPORTING_SUMMARIZED=openbank_ob_reporting_summarizeddb

# change user to root for elevated permissions to override inherited non-root user
USER root

# add Open Banking artifacts to base product
RUN \
wget -O ${WSO2_OB_TOOLKIT}.zip "${WSO2_OB_TOOLKIT_DIST_URL}" \
&& unzip -d ${WSO2_SERVER_HOME}/ ${WSO2_OB_TOOLKIT}.zip \
&& rm -f ${WSO2_OB_TOOLKIT}.zip

# copy the WSO2 OB BI UK Toolkit artifacts on top of WSO2 OBBI accelarator image
# Remove default AuthenticationDataSubmissionApp.siddhi
RUN \
rm ${WSO2_SERVER_HOME}/deployment/siddhi-files/AuthenticationDataSubmissionApp.siddhi \
# copy toolkit artifacts
&& cp -r ${WSO2_OB_TOOLKIT_DIR}/carbon-home/* "${WSO2_SERVER_HOME}"

# change directory rights
RUN chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME}/

# set MOTD login message for open banking
RUN echo ${MOTD} > "${ENV}"

# set the non-root user
USER ${USER_ID}

# expose server ports
EXPOSE 9712 9612 7712 7612 9092 9444

# initiate container and start WSO2 Carbon server
ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"]
82 changes: 82 additions & 0 deletions dockerfiles/alpine/obbi-uk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Dockerfile for WSO2 Open Banking Business Intelligence UK Toolkit Module
This section defines the step-by-step instructions to build an [Alpine](https://hub.docker.com/_/alpine/) Linux based Docker image for WSO2 Open Banking Business Intelligence UK Toolkit.

## Prerequisites

* [Docker](https://www.docker.com/get-docker) v20.10.10 or above
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) client
* WSO2 Open Banking API Manager UK Toolkit Module pack

+ Host the downloaded artifacts locally or on a remote location.
> The hosted locations of artifacts will be passed as the build arguments when building the Docker image.<br>
> 1. **WSO2_OB_TOOLKIT_DIST_URL** - UK Toolkit location

## 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-open-banking.git
```

> The local copy of the `dockerfiles/alpine/obbi-uk` directory will be referred to as `OBBI_UK_DOCKERFILE_HOME` from this point onwards.
##### 2. Build the Docker image.

- Navigate to `<OBBI_UK_DOCKERFILE_HOME>` directory. <br>
Execute `docker build` command as shown below.
+ `docker build --build-arg BASE_PRODUCT_VERSION=<APIM BASE PRODUCT VERSION> --build-arg WSO2_OB_TOOLKIT_DIST_URL=<URL_OF_THE_HOSTED_LOCATION/FILENAME> -t wso2-obbi-uk:1.0.0-alpine .` <br>
> eg:- **Hosted locally**: `docker build --build-arg BASE_PRODUCT_VERSION=4.2.0 --build-arg WSO2_OB_TOOLKIT_DIST_URL=http://localhost:8000/wso2-obbi-toolkit-uk-1.0.0.tar.gz -t wso2-obbi-toolkit-uk:1.0.0-alpine .` <br><br>
> eg:- **Hosted remotely**: `docker build --build-arg BASE_PRODUCT_VERSION=4.2.0 --build-arg WSO2_OB_TOOLKIT_DIST_URL=http://<public_ip:port>/wso2-obbi-toolkit-uk-1.0.0.tar.gz -t wso2-obbi-toolkit-uk:1.0.0-alpine .`
##### 3. Running the Docker image.

- `docker run -it -p 9712:9712 -p 9612:9612 -p 7712:7712 -p 7612:7612 -p 9092:9092 -p 9444:9444 wso2-obbi-uk:1.0.0-alpine`

## 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:

- Make sure that API Manager analytics is enabled in `<APIM_HOME>/repository/conf/deployment.toml` as follows.
```
[apim.analytics]
enable = true
```

- Go to `<APIM_HOME>/repository/conf/deployment.toml` and `<IS_HOME>/repository/conf/deployment.toml` to enable open banking data publishing as follows:

```
[open_banking.data_publishing]
enable = true
```

##### 1. Stop the OBBI container if it's already running.

In WSO2 Open Banking BI 3.0.0 product distribution, `deployment.yaml` configuration file <br>
can be found at `<DISTRIBUTION_HOME>/conf/server`. 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 1.

##### 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 9712:9712 -p 9612:9612 -p 7712:7712 -p 7612:7612 -p 9092:9092 -p 9444:9444 \
--volume <SOURCE_CONFIGS>/deployment.yaml:<TARGET_CONFIGS>/deployment.yaml \
wso2-obbi-uk:1.0.0-alpine
```

> In here, <TARGET_CONFIGS> refers to /home/wso2carbon/wso2si-4.0.0/conf/server 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 b9b60d6

Please sign in to comment.