Skip to content

Commit 3f0cdf0

Browse files
authored
Merge pull request #514 from npamudika/3.1.x
Add rocky linux based docker images for APIM
2 parents 9daeb59 + 6a3f748 commit 3f0cdf0

File tree

9 files changed

+822
-0
lines changed

9 files changed

+822
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# ------------------------------------------------------------------------
2+
#
3+
# Copyright 2024 WSO2, Inc. (http://wso2.com)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License
16+
#
17+
# ------------------------------------------------------------------------
18+
19+
# set base Docker image to CentOS Docker image
20+
FROM rockylinux:9.3
21+
22+
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
23+
24+
# install JDK Dependencies
25+
RUN yum install -y tzdata openssl ca-certificates fontconfig gzip tar \
26+
&& yum clean all
27+
28+
ENV JAVA_VERSION jdk-11.0.14+9
29+
30+
# install OpenJDK 11
31+
RUN set -eux; \
32+
ARCH="$(objdump="$(command -v objdump)" && objdump --file-headers "$objdump" | awk -F '[:,]+[[:space:]]+' '$1 == "architecture" { print $2 }')"; \
33+
case "${ARCH}" in \
34+
aarch64|arm64) \
35+
ESUM='0ba188a2a739733163cd0049344429d2284867e04ca452879be24f3b54320c9a'; \
36+
BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.14_9.tar.gz'; \
37+
;; \
38+
ppc64el|powerpc:common64) \
39+
ESUM='91c63331faba8c842aef312d415b3e67aecf4f662a36c275f5cb278f7bce1410'; \
40+
BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.14_9.tar.gz'; \
41+
;; \
42+
amd64|i386:x86-64) \
43+
ESUM='1189bee178d11402a690edf3fbba0c9f2ada1d3a36ff78929d81935842ef24a9'; \
44+
BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.14_9.tar.gz'; \
45+
;; \
46+
*) \
47+
echo "Unsupported arch: ${ARCH}"; \
48+
exit 1; \
49+
;; \
50+
esac; \
51+
curl -LfsSo /tmp/openjdk.tar.gz ${BINARY_URL}; \
52+
echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \
53+
mkdir -p /opt/java/openjdk; \
54+
cd /opt/java/openjdk; \
55+
tar -xf /tmp/openjdk.tar.gz --strip-components=1; \
56+
rm -rf /tmp/openjdk.tar.gz;
57+
58+
ENV JAVA_HOME=/opt/java/openjdk \
59+
PATH="/opt/java/openjdk/bin:$PATH"
60+
61+
# Verify Java installation
62+
RUN echo Verifying install ... \
63+
&& echo javac --version && javac --version \
64+
&& echo java --version && java --version \
65+
&& echo Complete.
66+
67+
LABEL maintainer="WSO2 Docker Maintainers <dev@wso2.org>" \
68+
com.wso2.docker.source="https://github.com/wso2/docker-apim/releases/tag/v3.1.0.5"
69+
70+
# set Docker image build arguments
71+
# build arguments for user/group configurations
72+
ARG USER=wso2carbon
73+
ARG USER_ID=802
74+
ARG USER_GROUP=wso2
75+
ARG USER_GROUP_ID=802
76+
ARG USER_HOME=/home/${USER}
77+
# build arguments for WSO2 product installation
78+
ARG WSO2_SERVER_NAME=wso2am-analytics
79+
ARG WSO2_SERVER_VERSION=3.1.0
80+
ARG WSO2_SERVER_REPOSITORY=product-apim
81+
ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION}
82+
ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER}
83+
ARG WSO2_SERVER_DIST_URL=https://github.com/wso2/${WSO2_SERVER_REPOSITORY}/releases/download/v${WSO2_SERVER_VERSION}/${WSO2_SERVER}.zip
84+
# build arguments for external artifacts
85+
ARG MYSQL_CONNECTOR_VERSION=8.0.17
86+
# build argument for MOTD
87+
ARG MOTD='printf "\n\
88+
Welcome to WSO2 Docker resources.\n\
89+
------------------------------------ \n\
90+
This Docker container comprises of a WSO2 product, running with its latest GA release \n\
91+
which is under the Apache License, Version 2.0. \n\
92+
Read more about Apache License, Version 2.0 here @ http://www.apache.org/licenses/LICENSE-2.0.\n\n"'
93+
94+
# create the non-root user and group and set MOTD login message
95+
RUN \
96+
groupadd --system -g ${USER_GROUP_ID} ${USER_GROUP} \
97+
&& useradd --system --create-home --home-dir ${USER_HOME} --no-log-init -g ${USER_GROUP_ID} -u ${USER_ID} ${USER} \
98+
&& echo ${MOTD} > /etc/profile.d/motd.sh
99+
100+
# copy init script to user home
101+
COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/
102+
# install required packages
103+
RUN \
104+
yum -y update \
105+
&& yum install -y \
106+
nc \
107+
unzip \
108+
wget \
109+
&& rm -rf /var/cache/yum/*
110+
# add the WSO2 product distribution to user's home directory
111+
RUN \
112+
wget -O ${WSO2_SERVER}.zip "${WSO2_SERVER_DIST_URL}" \
113+
&& unzip -d ${USER_HOME} ${WSO2_SERVER}.zip \
114+
&& chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \
115+
&& rm -f ${WSO2_SERVER}.zip
116+
117+
# set the user and work directory
118+
USER ${USER_ID}
119+
WORKDIR ${USER_HOME}
120+
121+
# set environment variables
122+
ENV WORKING_DIRECTORY=${USER_HOME} \
123+
WSO2_SERVER_HOME=${WSO2_SERVER_HOME}
124+
125+
# expose ports
126+
EXPOSE 9643 9092
127+
128+
# initiate container and start WSO2 Carbon server
129+
ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"]
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Dockerfile for Dashboard Profile of WSO2 API Manager Analytics #
2+
3+
This section defines the step-by-step instructions to build [Rocky Linux](https://hub.docker.com/_/rockylinux) based Docker image for for Dashboard profile of
4+
WSO2 API Manager Analytics 3.1.0.
5+
6+
## Prerequisites
7+
8+
* [Docker](https://www.docker.com/get-docker) v17.09.0 or above
9+
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) client
10+
11+
## How to build an image and run
12+
13+
##### 1. Checkout this repository into your local machine using the following Git client command.
14+
15+
```
16+
git clone https://github.com/wso2/docker-apim.git
17+
```
18+
19+
> The local copy of the `dockerfile/rocky/apim-analytics/dasboard` directory will be referred to as `ANALYTICS_DOCKERFILE_HOME` from this point onwards.
20+
21+
##### 2. Build the Docker image.
22+
23+
- Navigate to `<ANALYTICS_DOCKERFILE_HOME>` directory. <br>
24+
Execute `docker build` command as shown below.
25+
+ `docker build -t wso2am-analytics-dashboard:3.1.0-rocky .`
26+
> If you encounter issue related to downloading the product pack from hosted webserver, use the IP address of the network interface instead of `localhost` or `127.0.0.1` in the `WSO2_SERVER_DIST_URL`.
27+
28+
> By default, the Docker image will prepackage the General Availability (GA) release version of the relevant WSO2 product.
29+
30+
##### 3. Running Docker images specific to each profile.
31+
32+
- `docker run -p 9643:9643 wso2am-analytics-dashboard:3.1.0-rocky`
33+
34+
> Here, only port 9643 has been mapped to a Docker host port.
35+
You may map other container service ports, which have been exposed to Docker host ports, as desired.
36+
37+
##### 4. Accessing the Dashboard portal.
38+
39+
- For dashboard,
40+
+ `https:<DOCKER_HOST>:9643/analytics-dashboard`
41+
42+
> In here, <DOCKER_HOST> refers to hostname or IP of the host machine on top of which containers are spawned.
43+
44+
## How to update configurations
45+
46+
Configurations would lie on the Docker host machine and they can be volume mounted to the container. <br>
47+
As an example, steps required to change the port offset using `deployment.yaml` is as follows:
48+
49+
##### 1. Stop the API Manager Analytics container if it's already running.
50+
51+
In WSO2 API Manager Analytics version 3.1.0 product distribution, `deployment.yaml` configuration file <br>
52+
can be found at `<DISTRIBUTION_HOME>/conf/dashboard`. Copy the file to some suitable location of the host machine, <br>
53+
referred to as `<SOURCE_CONFIGS>/deployment.yaml` and change the `offset` value under `ports` to 1.
54+
55+
##### 2. Grant read permission to `other` users for `<SOURCE_CONFIGS>/deployment.yaml`.
56+
57+
```
58+
chmod o+r <SOURCE_CONFIGS>/deployment.yaml
59+
```
60+
61+
##### 3. Run the image by mounting the file to container as follows:
62+
63+
```
64+
docker run
65+
-p 9641:9641
66+
--volume <SOURCE_CONFIGS>/deployment.yaml:<TARGET_CONFIGS>/deployment.yaml
67+
wso2am-analytics-dashboard:3.1.0-rocky
68+
```
69+
70+
> In here, <TARGET_CONFIGS> refers to /home/wso2carbon/wso2am-analytics-3.1.0/conf/dashboard folder of the container.
71+
72+
## Docker command usage references
73+
74+
* [Docker build command reference](https://docs.docker.com/engine/reference/commandline/build/)
75+
* [Docker run command reference](https://docs.docker.com/engine/reference/run/)
76+
* [Dockerfile reference](https://docs.docker.com/engine/reference/builder/)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
# ------------------------------------------------------------------------
3+
# Copyright 2024 WSO2, Inc. (http://wso2.com)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License
16+
# ------------------------------------------------------------------------
17+
18+
set -e
19+
20+
# volume mounts
21+
config_volume=${WORKING_DIRECTORY}/wso2-config-volume
22+
artifact_volume=${WORKING_DIRECTORY}/wso2-artifact-volume
23+
24+
# check if the WSO2 non-root user home exists
25+
test ! -d ${WORKING_DIRECTORY} && echo "WSO2 Docker non-root user home does not exist" && exit 1
26+
27+
# check if the WSO2 product home exists
28+
test ! -d ${WSO2_SERVER_HOME} && echo "WSO2 Docker product home does not exist" && exit 1
29+
30+
# copy any configuration changes mounted to config_volume
31+
test -d ${config_volume} && [ "$(ls -A ${config_volume})" ] && cp -RL ${config_volume}/* ${WSO2_SERVER_HOME}/
32+
# copy any artifact changes mounted to artifact_volume
33+
test -d ${artifact_volume} && [ "$(ls -A ${artifact_volume})" ] && cp -RL ${artifact_volume}/* ${WSO2_SERVER_HOME}/
34+
35+
# start WSO2 Carbon server
36+
sh ${WSO2_SERVER_HOME}/bin/dashboard.sh "$@"
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# ------------------------------------------------------------------------
2+
#
3+
# Copyright 2024 WSO2, Inc. (http://wso2.com)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License
16+
#
17+
# ------------------------------------------------------------------------
18+
19+
# set base Docker image to Rocky Linux
20+
FROM rockylinux:9.3
21+
22+
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
23+
24+
# install JDK Dependencies
25+
RUN yum install -y tzdata openssl ca-certificates fontconfig gzip tar \
26+
&& yum clean all
27+
28+
ENV JAVA_VERSION jdk-11.0.14+9
29+
30+
# install OpenJDK 11
31+
RUN set -eux; \
32+
ARCH="$(objdump="$(command -v objdump)" && objdump --file-headers "$objdump" | awk -F '[:,]+[[:space:]]+' '$1 == "architecture" { print $2 }')"; \
33+
case "${ARCH}" in \
34+
aarch64|arm64) \
35+
ESUM='0ba188a2a739733163cd0049344429d2284867e04ca452879be24f3b54320c9a'; \
36+
BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.14_9.tar.gz'; \
37+
;; \
38+
ppc64el|powerpc:common64) \
39+
ESUM='91c63331faba8c842aef312d415b3e67aecf4f662a36c275f5cb278f7bce1410'; \
40+
BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.14_9.tar.gz'; \
41+
;; \
42+
amd64|i386:x86-64) \
43+
ESUM='1189bee178d11402a690edf3fbba0c9f2ada1d3a36ff78929d81935842ef24a9'; \
44+
BINARY_URL='https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.14_9.tar.gz'; \
45+
;; \
46+
*) \
47+
echo "Unsupported arch: ${ARCH}"; \
48+
exit 1; \
49+
;; \
50+
esac; \
51+
curl -LfsSo /tmp/openjdk.tar.gz ${BINARY_URL}; \
52+
echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \
53+
mkdir -p /opt/java/openjdk; \
54+
cd /opt/java/openjdk; \
55+
tar -xf /tmp/openjdk.tar.gz --strip-components=1; \
56+
rm -rf /tmp/openjdk.tar.gz;
57+
58+
ENV JAVA_HOME=/opt/java/openjdk \
59+
PATH="/opt/java/openjdk/bin:$PATH"
60+
61+
# Verify Java installation
62+
RUN echo Verifying install ... \
63+
&& echo javac --version && javac --version \
64+
&& echo java --version && java --version \
65+
&& echo Complete.
66+
67+
LABEL maintainer="WSO2 Docker Maintainers <dev@wso2.org>" \
68+
com.wso2.docker.source="https://github.com/wso2/docker-apim/releases/tag/v3.1.0.5"
69+
70+
# set Docker image build arguments
71+
# build arguments for user/group configurations
72+
ARG USER=wso2carbon
73+
ARG USER_ID=802
74+
ARG USER_GROUP=wso2
75+
ARG USER_GROUP_ID=802
76+
ARG USER_HOME=/home/${USER}
77+
# build arguments for WSO2 product installation
78+
ARG WSO2_SERVER_NAME=wso2am-analytics
79+
ARG WSO2_SERVER_VERSION=3.1.0
80+
ARG WSO2_SERVER_REPOSITORY=product-apim
81+
ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION}
82+
ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER}
83+
ARG WSO2_SERVER_DIST_URL=https://github.com/wso2/${WSO2_SERVER_REPOSITORY}/releases/download/v${WSO2_SERVER_VERSION}/${WSO2_SERVER}.zip
84+
# build arguments for external artifacts
85+
ARG MYSQL_CONNECTOR_VERSION=8.0.17
86+
# build argument for MOTD
87+
ARG MOTD='printf "\n\
88+
Welcome to WSO2 Docker resources.\n\
89+
------------------------------------ \n\
90+
This Docker container comprises of a WSO2 product, running with its latest GA release \n\
91+
which is under the Apache License, Version 2.0. \n\
92+
Read more about Apache License, Version 2.0 here @ http://www.apache.org/licenses/LICENSE-2.0.\n\n"'
93+
94+
# create the non-root user and group and set MOTD login message
95+
RUN \
96+
groupadd --system -g ${USER_GROUP_ID} ${USER_GROUP} \
97+
&& useradd --system --create-home --home-dir ${USER_HOME} --no-log-init -g ${USER_GROUP_ID} -u ${USER_ID} ${USER} \
98+
&& echo ${MOTD} > /etc/profile.d/motd.sh
99+
100+
# copy init script to user home
101+
COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/
102+
# install required packages
103+
RUN \
104+
yum -y update \
105+
&& yum install -y \
106+
nc \
107+
unzip \
108+
wget \
109+
&& rm -rf /var/cache/yum/*
110+
# add the WSO2 product distribution to user's home directory
111+
RUN \
112+
wget -O ${WSO2_SERVER}.zip "${WSO2_SERVER_DIST_URL}" \
113+
&& unzip -d ${USER_HOME} ${WSO2_SERVER}.zip \
114+
&& chown wso2carbon:wso2 -R ${WSO2_SERVER_HOME} \
115+
&& rm -f ${WSO2_SERVER}.zip
116+
117+
# set the user and work directory
118+
USER ${USER_ID}
119+
WORKDIR ${USER_HOME}
120+
121+
# set environment variables
122+
ENV WORKING_DIRECTORY=${USER_HOME} \
123+
WSO2_SERVER_HOME=${WSO2_SERVER_HOME}
124+
125+
# expose ports
126+
EXPOSE 9091 9444 7712 7612 9612 9712 7444 7071
127+
128+
# initiate container and start WSO2 Carbon server
129+
ENTRYPOINT ["/home/wso2carbon/docker-entrypoint.sh"]

0 commit comments

Comments
 (0)