Skip to content

Commit

Permalink
Change scripts to compatible with jenkins process
Browse files Browse the repository at this point in the history
  • Loading branch information
RidmiR authored and chirangaalwis committed Jul 21, 2020
1 parent 21fa696 commit 59b8a15
Show file tree
Hide file tree
Showing 39 changed files with 745 additions and 739 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog
All notable changes to this project 2.5.x per each release will be documented in this file.

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

## [v2.5.0.2] - 2020-07-16

### Changed
- In the current Docker image build process it is instructed to copy the relevant JDK, Product pack and the MySQL JDBC connector to the file directory and in the Dockerfile its copying the files from the file directory. In order to compatible with WSO2 Docker image create automation process, this has been changed to get the product pack from WUM, JDK from the Jenkins and MySQL from the Maven central repository.

- Change the name of the ENTRYPOINT script as docker-entrypoint.sh

### Removed
- Remove copying the JDK and product pack from file directory

[v2.5.0.1]: https://github.com/wso2/docker-apim/compare/v2.5.0.1...v2.5.0.2
81 changes: 43 additions & 38 deletions dockerfiles/alpine/apim-analytics/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,63 @@ 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=wso2am-analytics
# build arguments for WSO2 product installation
ARG WSO2_SERVER_NAME=wso2am-analytics
ARG WSO2_SERVER_VERSION=2.5.0
ARG WSO2_SERVER_PACK=${WSO2_SERVER}-${WSO2_SERVER_VERSION}
ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER_PACK}
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
# build arguments for external artifacts
ARG MYSQL_CONNECTOR_VERSION=5.1.49
# 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"
# install required packages
RUN apk add --update --no-cache \
curl \
netcat-openbsd && \
rm -rf /var/cache/apk/* && \
echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/motd' \
>> /etc/bash.bashrc \
; echo "\n\
Welcome to WSO2 Docker Resources \n\
--------------------------------- \n\
This Docker container comprises of a WSO2 product, running with its latest updates \n\
which are under the End User License Agreement (EULA) 2.0. \n\
Read more about EULA 2.0 here @ https://wso2.com/licenses/wso2-update/2.0 \n" \
> /etc/motd
# 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 docker-entrypoint script to user home
COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/
# 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} ;
# install required packages
RUN \
apk add --no-cache \
wget \
unzip \
bash \
libxml2-utils \
netcat-openbsd
# install Alpine Linux package to run binaries linked against glibc
RUN apk --no-cache add ca-certificates wget; \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub; \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.27-r0/glibc-2.27-r0.apk; \
apk add glibc-2.27-r0.apk;
# 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
# copy wso2 product distribution zip files to user's home directory and set ownership
COPY --chown=wso2carbon:wso2 ${FILES}/${WSO2_SERVER_PACK}/ ${WSO2_SERVER_HOME}/
# copy shared artifacts to a temporary location
COPY --chown=wso2carbon:wso2 ${FILES}/${WSO2_SERVER_PACK}/repository/deployment/ ${USER_HOME}/wso2-tmp/deployment/
# copy init script to user home
COPY --chown=wso2carbon:wso2 init.sh ${USER_HOME}/
# copy mysql connector jar to the server as a third party library
COPY --chown=wso2carbon:wso2 ${FILES}/mysql-connector-java-*-bin.jar ${WSO2_SERVER_HOME}/repository/components/lib/
ADD --chown=wso2carbon:wso2 https://repo1.maven.org/maven2/org/xerial/snappy/snappy-java/1.1.1.7/snappy-java-1.1.1.7.jar ${USER_HOME}/${WSO2_SERVER_PACK}/repository/components/lib/
# add libraries for Kubernetes membership scheme based clustering
ADD --chown=wso2carbon:wso2 https://repo1.maven.org/maven2/dnsjava/dnsjava/2.1.8/dnsjava-2.1.8.jar ${WSO2_SERVER_HOME}/repository/components/lib/
ADD --chown=wso2carbon:wso2 https://repo1.maven.org/maven2/org/wso2/carbon/kubernetes/artifacts/kubernetes-membership-scheme/1.0.5/kubernetes-membership-scheme-1.0.5.jar ${WSO2_SERVER_HOME}/repository/components/dropins/
# 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 \
&& chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \
&& mkdir ${USER_HOME}/wso2-tmp \
&& cp -r ${WSO2_SERVER_HOME}/repository/deployment ${USER_HOME}/wso2-tmp \
&& rm -f ${WSO2_SERVER}.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}/repository/components/dropins/
# set environment variables
ENV WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER_PACK} \
Expand All @@ -93,5 +98,5 @@ ENV WORKING_DIRECTORY=${USER_HOME}
# expose ports
EXPOSE 9764 9444 7712 7612 4041
# initiate container and start WSO2 Carbon server
ENTRYPOINT ${WORKING_DIRECTORY}/init.sh
# initiate container and start WSO2 Carbon Server
ENTRYPOINT ${WORKING_DIRECTORY}/docker-entrypoint.sh
38 changes: 16 additions & 22 deletions dockerfiles/alpine/apim-analytics/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Dockerfile for WSO2 API Manager #
The section defines the step-by-step instructions to build an Alpine OpenJDK Docker image for WSO2 API Manager 2.5.0.
The section defines the step-by-step instructions to build an Alpine OpenJDK Docker image for WSO2 API Manager Analytics 2.5.0.

## Prerequisites

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

* [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
* WSO2 API Manager Analytics downloaded through [WUM](https://wso2.com/wum/download)
* Download JDK 8 through [Oracle](https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html)
- Host the downloaded pack and JDK locally or on a remote location.
>The hosted product pack location and JDK location will be passed as the build arguments WSO2_SERVER_DIST_URL and JDK_URL when building the Docker image.
## How to build an image and run
##### 1. Checkout this repository into your local machine using the following git command.
Expand All @@ -14,37 +19,26 @@ git clone https://github.com/wso2/docker-apim.git

>The local copy of the `dockerfile/apim-analytics` directory will be referred to as `ANALYTICS_DOCKERFILE_HOME` from this point onwards.
##### 2. Add WSO2 APIM Server distribution and MySQL connector jar file to `<ANALYTICS_DOCKERFILE_HOME>/files`
- Download the [WSO2 APIM Server Analytics v2.5.0](http://wso2.com/api-management/try-it/)
distribution and extract it to `<ANALYTICS_DOCKERFILE_HOME>/files`.
- Download [MySQL Connector/J v5.1.45](https://downloads.mysql.com/archives/c-j) and then copy that to `<ANALYTICS_DOCKERFILE_HOME>/files`.<br>
- Once all of these are in place, it should look as follows:

```bash
<ANALYTICS_DOCKERFILE_HOME>/files/wso2am-analytics-2.5.0/
<ANALYTICS_DOCKERFILE_HOME>/files/mysql-connector-java-5.1.45-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 Docker image.
##### 2. Build the Docker image.
- Navigate to `<ANALYTICS_DOCKERFILE_HOME>` directory. <br>
Execute `docker build` command as shown below.
+ `docker build -t wso2am-analytics:2.5.0-alpine .`

##### 4. Running the Docker image.

+ `docker build --build-arg WSO2_SERVER_DIST_URL=<URL_OF_THE_HOSTED_LOCATION/FILENAME> JDK_URL=<URL_OF_THE_HOSTED_JDK_LOCATION/FILENAME> -t wso2am-analytics:2.5.0-alpine .`
- eg:- Hosted locally: docker build --build-arg WSO2_SERVER_DIST_URL=http://172.17.0.1:8000/wso2am-analytics.zip JDK_URL=http://172.17.0.1:8000/jdk-8u261-linux-x64.tar.gz -t wso2am-analytics:2.5.0-alpine .
- eg:- Hosted remotely: docker build --build-arg WSO2_SERVER_DIST_URL=http://<public_ip:port>/wso2am-analytics.zip JDK_URL=http://172.17.0.1:8000/jdk-8u261-linux-x64.tar.gz -t wso2am-analytics:2.5.0-alpine .

##### 3. Running the Docker image.
- docker run -it -p 9444:9444 wso2am-analytics:2.5.0-alpine

##### 5. Accessing management console.
- To access the Identity Server Analytics Dashboard, user docker host IP and port 9444.
+ `https://<DOCKER_HOST>:9444/portal/dashboards/IsAnalytics-AuthenticationData/`
##### 4. Accessing management console.
- To access the management console, use the docker host IP and port 9444.
+ `https://<DOCKER_HOST>:9444/carbon`
+ `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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/sh
# ------------------------------------------------------------------------
# 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.
# Copyright (c) 2020 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you 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
# ------------------------------------------------------------------------
# limitations under the License.
# ----------------------------------------------------------------------------
set -e

# volume mounts
Expand Down Expand Up @@ -53,9 +55,6 @@ verifyMountBeforeStart ${config_volume}
verification_count=0
verifyMountBeforeStart ${artifact_volume}

# capture Docker container IP from the container's /etc/hosts file
docker_container_ip=$(awk 'END{print $1}' /etc/hosts)

# 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

Expand All @@ -67,11 +66,5 @@ test -d ${config_volume}/ && cp -RL ${config_volume}/* ${WSO2_SERVER_HOME}/
# copy any artifact changes mounted to artifact_volume
test -d ${artifact_volume}/ && cp -RL ${artifact_volume}/* ${WSO2_SERVER_HOME}/

# make any node specific configuration changes
# set the Docker container IP as the `localMemberHost` under axis2.xml clustering configurations (effective only when clustering is enabled)
sed -i "s#<parameter\ name=\"localMemberHost\".*<\/parameter>#<parameter\ name=\"localMemberHost\">${docker_container_ip}<\/parameter>#" ${WSO2_SERVER_HOME}/repository/conf/axis2/axis2.xml
# replace host name entries (hard-coded with `wso2is-with-analytics-is-analytics`), with the Docker container IP in event-processor.xml file
sed -i "s#<hostName>wso2is-with-analytics-is-analytics</hostName>#<hostName>${docker_container_ip}</hostName>#" ${WSO2_SERVER_HOME}/repository/conf/event-processor.xml

# start WSO2 Carbon server
sh ${WSO2_SERVER_HOME}/bin/wso2server.sh
sh ${WSO2_SERVER_HOME}/bin/wso2server.sh "$@"
Empty file.
81 changes: 45 additions & 36 deletions dockerfiles/alpine/apim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,63 +26,72 @@ 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=wso2am
ARG WSO2_SERVER_VERSION=2.5.0
ARG WSO2_SERVER_PACK=${WSO2_SERVER}-${WSO2_SERVER_VERSION}
ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER_PACK}
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
# build arguments for external artifacts
ARG MYSQL_CONNECTOR_VERSION=5.1.49
# 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"
# install required packages
RUN apk add --update --no-cache \
curl \
netcat-openbsd && \
rm -rf /var/cache/apk/* && \
echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/motd' \
>> /etc/bash.bashrc \
; echo "\n\
Welcome to WSO2 Docker Resources \n\
--------------------------------- \n\
This Docker container comprises of a WSO2 product, running with its latest updates \n\
which are under the End User License Agreement (EULA) 2.0. \n\
Read more about EULA 2.0 here @ https://wso2.com/licenses/wso2-update/2.0 \n" \
> /etc/motd
# 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} ;
# 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}"
# 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
# copy wso2 product distribution zip files to user's home directory and set ownership
COPY --chown=wso2carbon:wso2 ${FILES}/${WSO2_SERVER_PACK}/ ${USER_HOME}/${WSO2_SERVER_PACK}/
# copy shared artifacts to a temporary location
COPY --chown=wso2carbon:wso2 ${FILES}/${WSO2_SERVER_PACK}/repository/deployment/ ${USER_HOME}/wso2-tmp/deployment/
# copy init script to user home
COPY --chown=wso2carbon:wso2 init.sh ${USER_HOME}/
# copy mysql connector jar to the server as a third party library
COPY --chown=wso2carbon:wso2 ${FILES}/mysql-connector-java-*-bin.jar ${WSO2_SERVER_HOME}/repository/components/lib/
# copy docker-entrypoint script to user home
COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/
# install required packages
RUN \
apk add --no-cache \
wget \
unzip \
bash \
libxml2-utils \
netcat-openbsd
# 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 \
&& chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \
&& mkdir ${USER_HOME}/wso2-tmp \
&& cp -r ${WSO2_SERVER_HOME}/repository/deployment ${USER_HOME}/wso2-tmp \
&& rm -f ${WSO2_SERVER}.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}/repository/components/dropins/
# add libraries for Kubernetes membership scheme based clustering
ADD --chown=wso2carbon:wso2 https://repo1.maven.org/maven2/dnsjava/dnsjava/2.1.8/dnsjava-2.1.8.jar ${WSO2_SERVER_HOME}/repository/components/lib/
ADD --chown=wso2carbon:wso2 https://repo1.maven.org/maven2/org/wso2/carbon/kubernetes/artifacts/kubernetes-membership-scheme/1.0.5/kubernetes-membership-scheme-1.0.5.jar ${WSO2_SERVER_HOME}/repository/components/dropins/
# 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"
# set the user and work directory
USER ${USER_ID}
WORKDIR ${USER_HOME}
# expose ports
EXPOSE 8280 8243 9763 9443 9099 5672 9711 9611 7711 7611 10397
# initiate container and start WSO2 Carbon server
ENTRYPOINT ${WORKING_DIRECTORY}/init.sh
ENTRYPOINT ${WORKING_DIRECTORY}/docker-entrypoint.sh
Loading

0 comments on commit 59b8a15

Please sign in to comment.