TSK-1619: added Dockerfile for our db2 image
This commit is contained in:
parent
c96117afb6
commit
e4a5a12ec9
|
@ -270,7 +270,7 @@ jobs:
|
|||
name: ${{ env.ARTIFACTS_TASKANA_JARS_NAME }}
|
||||
path: ${{ env.ARTIFACTS_TASKANA_JARS_PATH }}
|
||||
- name: Prepare database
|
||||
run: ci/prepare_db.sh ${{ matrix.database }}
|
||||
run: docker-databases/prepare_db.sh ${{ matrix.database }}
|
||||
- name: Generate JavaDoc for Rest Documentation
|
||||
if: matrix.module == 'taskana-simplehistory-rest-spring'
|
||||
run: ./mvnw -B validate -pl :taskana-rest-spring
|
||||
|
@ -312,7 +312,7 @@ jobs:
|
|||
name: ${{ env.ARTIFACTS_TASKANA_JARS_NAME }}
|
||||
path: ${{ env.ARTIFACTS_TASKANA_JARS_PATH }}
|
||||
- name: Start database
|
||||
run: ci/prepare_db.sh POSTGRES_10
|
||||
run: docker-databases/prepare_db.sh POSTGRES_10
|
||||
- name: Test
|
||||
run: ./mvnw -B verify -f rest/taskana-rest-spring-example-wildfly
|
||||
- name: Cancel workflow
|
||||
|
|
|
@ -67,3 +67,6 @@ Thumbs.db
|
|||
|
||||
# java-format
|
||||
.java-format-cache
|
||||
|
||||
# DB2 database
|
||||
db.tar.gz
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
# Build docker image of db2 express-C v10.5 FP5 (64bit)
|
||||
#
|
||||
# # Authors:
|
||||
# * Leo (Zhong Yu) Wu <leow@ca.ibm.com>
|
||||
#
|
||||
# Copyright 2015, IBM Corporation
|
||||
#
|
||||
# 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 centos:7
|
||||
|
||||
###############################################################
|
||||
#
|
||||
# System preparation for DB2
|
||||
#
|
||||
###############################################################
|
||||
|
||||
RUN groupadd db2iadm1 && useradd -G db2iadm1 db2inst1
|
||||
|
||||
# Required packages
|
||||
RUN yum install -y \
|
||||
vi \
|
||||
sudo \
|
||||
passwd \
|
||||
pam \
|
||||
pam.i686 \
|
||||
ncurses-libs.i686 \
|
||||
file \
|
||||
libaio \
|
||||
libstdc++-devel.i686 \
|
||||
numactl-libs \
|
||||
which \
|
||||
glibc-locale-source \
|
||||
glibc-langpack-de \
|
||||
&& yum clean all
|
||||
|
||||
RUN localedef -i de_DE -c -f UTF-8 \
|
||||
-A /usr/share/locale/locale.alias de_DE.UTF-8 && echo "LANG=de_DE.UTF-8" > /etc/locale.conf
|
||||
RUN echo "export LANG=de_DE.UTF-8" >> /etc/profile
|
||||
|
||||
COPY ./db.tar.gz /tmp/expc.tar.gz
|
||||
|
||||
RUN cd /tmp && tar xf expc.tar.gz \
|
||||
&& su - db2inst1 -c "/tmp/expc/db2_install -y -b /home/db2inst1/sqllib" \
|
||||
&& echo '. /home/db2inst1/sqllib/db2profile' >> /home/db2inst1/.bash_profile \
|
||||
&& rm -rf /tmp/db2* && rm -rf /tmp/expc* \
|
||||
&& sed -ri 's/(ENABLE_OS_AUTHENTICATION=).*/\1YES/g' /home/db2inst1/sqllib/instance/db2rfe.cfg \
|
||||
&& sed -ri 's/(RESERVE_REMOTE_CONNECTION=).*/\1YES/g' /home/db2inst1/sqllib/instance/db2rfe.cfg \
|
||||
&& sed -ri 's/^\*(SVCENAME=db2c_db2inst1)/\1/g' /home/db2inst1/sqllib/instance/db2rfe.cfg \
|
||||
&& sed -ri 's/^\*(SVCEPORT)=48000/\1=50000/g' /home/db2inst1/sqllib/instance/db2rfe.cfg
|
||||
|
||||
RUN su - db2inst1 -c "db2start && db2set DB2COMM=TCPIP \
|
||||
&& db2set -g -null DB2_COMPATIBILITY_VECTOR \
|
||||
&& db2 create database TSKDB using codeset utf-8 territory en-us \
|
||||
collate using 'CLDR181_LDE_AS_CX_EX_FX_HX_NX_S3' PAGESIZE 32 K" \
|
||||
&& su - db2inst1 -c "db2stop force" \
|
||||
&& cd /home/db2inst1/sqllib/instance \
|
||||
&& ./db2rfe -f ./db2rfe.cfg
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["start"]
|
||||
|
||||
EXPOSE 50000
|
|
@ -0,0 +1,5 @@
|
|||
# How to build the IBM DB2 Express-C docker image
|
||||
|
||||
1. Download the database from either [IBM directly](https://www-01.ibm.com/marketing/iwm/iwm/web/pickUrxNew.do?source=swg-db2expressc) or from our [NT Onedrive](https://msnovatec-my.sharepoint.com/:f:/g/personal/mzo_novatec-gmbh_de/EuxS9esUxppHn-1Mobq7UT4BVWbwXga585q7o3h6hzAC6g?e=PK3KdM) (NT employees only)
|
||||
2. Name that tar file `db.tar.gz` and place it in this folder
|
||||
3. Execute a docker build command
|
|
@ -0,0 +1,105 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Initialize DB2 instance in a Docker container
|
||||
#
|
||||
# # Authors:
|
||||
# * Leo (Zhong Yu) Wu <leow@ca.ibm.com>
|
||||
# * Boris Manojlovic <boris@steki.net>
|
||||
#
|
||||
# Copyright 2015, IBM Corporation
|
||||
#
|
||||
# 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.
|
||||
|
||||
pid=0
|
||||
|
||||
function log_info {
|
||||
echo -e $(date '+%Y-%m-%d %T')"\e[1;32m $@\e[0m"
|
||||
}
|
||||
|
||||
function log_error {
|
||||
echo -e >&2 $(date +"%Y-%m-%d %T")"\e[1;31m $@\e[0m"
|
||||
}
|
||||
|
||||
function stop_db2 {
|
||||
log_info "stopping database engine"
|
||||
su - db2inst1 -c "db2stop force"
|
||||
}
|
||||
|
||||
function start_db2 {
|
||||
log_info "starting database engine"
|
||||
su - db2inst1 -c "db2start"
|
||||
}
|
||||
|
||||
function restart_db2 {
|
||||
# if you just need to restart db2 and not to kill this container
|
||||
# use docker kill -s USR1 <container name>
|
||||
kill ${spid}
|
||||
log_info "Asked for instance restart doing it..."
|
||||
stop_db2
|
||||
start_db2
|
||||
log_info "database instance restarted on request"
|
||||
}
|
||||
|
||||
function terminate_db2 {
|
||||
kill ${spid}
|
||||
stop_db2
|
||||
if [ $pid -ne 0 ]; then
|
||||
kill -SIGTERM "$pid"
|
||||
wait "$pid"
|
||||
fi
|
||||
log_info "database engine stopped"
|
||||
exit 0 # finally exit main handler script
|
||||
}
|
||||
|
||||
trap "terminate_db2" SIGTERM
|
||||
trap "restart_db2" SIGUSR1
|
||||
|
||||
if [ ! -f ~/db2inst1_pw_set ]; then
|
||||
(echo "db2inst1-pwd"; echo "db2inst1-pwd") | passwd db2inst1 > /dev/null 2>&1
|
||||
if [ $? != 0 ];then
|
||||
log_error "Changing password for db2inst1 failed"
|
||||
exit 1
|
||||
fi
|
||||
touch ~/db2inst1_pw_set
|
||||
fi
|
||||
|
||||
if [ ! -f ~/db2_license_accepted ];then
|
||||
if [ -z "$LICENSE" ];then
|
||||
log_error "error: LICENSE not set"
|
||||
log_error "Did you forget to add '-e LICENSE=accept' ?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${LICENSE}" != "accept" ];then
|
||||
log_error "error: LICENSE not set to 'accept'"
|
||||
log_error "Please set '-e LICENSE=accept' to accept License before use the DB2 software contained in this image."
|
||||
exit 1
|
||||
fi
|
||||
touch ~/db2_license_accepted
|
||||
fi
|
||||
|
||||
if [[ $1 = "start" ]]; then
|
||||
log_info "Initializing container"
|
||||
start_db2
|
||||
log_info "Database db2diag log following"
|
||||
tail -f ~db2inst1/sqllib/db2dump/db2diag.log &
|
||||
export pid=${!}
|
||||
while true
|
||||
do
|
||||
sleep 10000 &
|
||||
export spid=${!}
|
||||
wait $spid
|
||||
done
|
||||
else
|
||||
exec "$1"
|
||||
fi
|
|
@ -1,12 +1,14 @@
|
|||
version: '3'
|
||||
services:
|
||||
taskana-postgres_10:
|
||||
build: .
|
||||
build: postgres_10
|
||||
ports:
|
||||
- 5102:5432
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
taskana-db2_11-1:
|
||||
image: taskana/db2:11.1
|
||||
environment:
|
||||
- LICENSE=accept
|
||||
ports:
|
||||
- 5101:50000
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
set -e #fail fast
|
||||
trap "exit 1" TERM
|
||||
export TOP_PID=$$
|
||||
|
||||
#H Usage:
|
||||
#H %FILE% -h | %FILE% --help
|
||||
|
@ -39,7 +41,7 @@ function mapDBToDockerComposeServiceName() {
|
|||
echo "taskana-postgres_10"
|
||||
;;
|
||||
*)
|
||||
echo "unknown database '$1'" >&2 && exit 1
|
||||
echo "unknown database '$1'" >&2 && kill -s TERM $TOP_PID
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -71,8 +73,11 @@ function main() {
|
|||
echo 'schemaName=taskana' >> $propFile
|
||||
;;
|
||||
stop)
|
||||
docker-compose -f $scriptDir/docker-compose.yml rm -f -s -v "$(mapDBToDockerComposeServiceName "$2")"
|
||||
|
||||
# this variable is necessary, so that the script can terminate properly
|
||||
# when the provided database name does not match. PLEASE DO NOT INLINE!
|
||||
local composeServiceName="$(mapDBToDockerComposeServiceName "$2")"
|
||||
docker-compose -f $scriptDir/docker-compose.yml rm -f -s -v $composeServiceName
|
||||
|
||||
[[ -f "$propFile" ]] && rm "$propFile"
|
||||
;;
|
||||
*)
|
Loading…
Reference in New Issue