Skip to content

Commit

Permalink
New EclipseLik build image 2.0.0 with MySQL 8 (#1476)
Browse files Browse the repository at this point in the history
This PR contains new Maven project to build and publish Docker image used in various build environments.
Released image 2.0.0 is applied in Jenkins pipelines.
It contains upgrade into MySQL 8.0 DB plus related changes (JDBC driver/class name and some JDBC URL properties).

Signed-off-by: Tomas Kraus <tomas.kraus@oracle.com>
Co-authored-by: Radek Felcman <radek.felcman@oracle.com>
  • Loading branch information
Tomas-Kraus and rfelcman authored Apr 12, 2022
1 parent 3c40ddd commit f772522
Show file tree
Hide file tree
Showing 13 changed files with 594 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ target/
.idea/
test_*.properties
.sonar
*~
12 changes: 7 additions & 5 deletions etc/el-test.mysql.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -11,14 +11,16 @@
#

# DB Connection properties
db.driver=com.mysql.jdbc.Driver
db.xa.driver=com.mysql.jdbc.Driver
db.driver=com.mysql.cj.jdbc.Driver
db.xa.driver=com.mysql.cj.jdbc.Driver
#db.xa.driver=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
db.url=jdbc:mysql://localhost:3306/ecltests?useSSL=false
db.url=jdbc:mysql://localhost:3306/ecltests?allowPublicKeyRetrieval=true
db.root.pwd=root
db.user=root
db.pwd=root
db.platform=org.eclipse.persistence.platform.database.MySQLPlatform
db.properties=url=jdbc:mysql://localhost:3306/ecltests;useSSL=false
# Used in JEE server side tests to setup datasource by Maven Cargo plugin
db.properties=url=jdbc:mysql://localhost:3306/ecltests?allowPublicKeyRetrieval=true
#db.ddl.debug=true
datasource.type=java.sql.Driver
#datasource.type=javax.sql.XADataSource
Expand Down
4 changes: 2 additions & 2 deletions etc/jenkins/build.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved.
// Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -75,7 +75,7 @@ spec:
requests:
memory: "12Gi"
cpu: "5.5"
image: tkraus/el-build:1.1.9
image: tkraus/el-build:2.0.0
volumeMounts:
- name: tools
mountPath: /opt/tools
Expand Down
22 changes: 22 additions & 0 deletions etc/jenkins/docker/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.

# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0,
# or the Eclipse Distribution License v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.

# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

# Eclipse Foundation build infrastructure Docker image for EclipseLiunk builds
FROM ${docker.source}

ADD ${java.pkg} ${ant.pkg} ${maven.pkg} ${install.java}/

ADD mongo-start.sh mongo-stop.sh mysql-start.sh mysql-stop.sh ${install.scripts}/

ADD install.sh ${mysql.pkg} /tmp/

RUN chmod u+x /tmp/install.sh \
&& /tmp/install.sh > /tmp/install.log 2>&1 \
&& rm -vf /tmp/install.sh /tmp/${mysql.pkg}
150 changes: 150 additions & 0 deletions etc/jenkins/docker/image/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/bin/sh
#
# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.

# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0,
# or the Eclipse Distribution License v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.

# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

# This script file is processed with Maven resource filtering
# so variables expansion must be used with respect to defined
# maven POM properties.

# Docker image installation file
# Print timestamp and message to sdtout
# Arguments:
# $1 First message to be printed
# $2 Second message to be printed
# ...
print() {
echo '['`date '+%d.%m.%Y %H:%M:%S'`'] '$@
}

JENKINS_USER='${build.user.name}'
JENKINS_UID='${build.user.uid}'
JENKINS_GROUP='${build.group.name}'
JENKINS_GID='${build.group.gid}'

INSTALL_JAVA='${install.java}'

print "Adding Jenkins group ${JENKINS_GROUP}:${JENKINS_GID}"
groupadd -g "${JENKINS_GID}" "${JENKINS_GROUP}"

print "Adding Jenkins user ${JENKINS_USER}:${JENKINS_UID}"
useradd -u "${JENKINS_UID}" -g "${JENKINS_GID}" \
-s '${build.user.shell}' -c '${build.user.comment}' \
-m "${JENKINS_USER}"

print "Updating the system"
echo '--------------------------------------------------------------------------------'
yum -y update
yum -y install git
echo '--------------------------------------------------------------------------------'

print "Configuring Java tools in ${INSTALL_JAVA}"

JDK_PATH=''
for i in `ls ${INSTALL_JAVA} | grep 'jdk-'`; do
JDK_PATH="${JDK_PATH}:${INSTALL_JAVA}/${i}/bin"
done
print " - Open JDK ${JDK_PATH}"

ANT_PATH=''
for i in `ls ${INSTALL_JAVA} | grep '\-ant-'`; do
ANT_PATH="${ANT_PATH}:${INSTALL_JAVA}/${i}/bin"
done
print " - Apache Ant ${ANT_PATH}"

MVN_PATH=''
for i in `ls ${INSTALL_JAVA} | grep '\-maven-'`; do
MVN_PATH="${MVN_PATH}:${INSTALL_JAVA}/${i}/bin"
done
print " - Apache Maven ${MVN_PATH}"

if [ -n "${JDK_PATH}" ]; then
TOOLS_PATH="${JDK_PATH}"
else
TOOLS_PATH=''
fi
if [ -n "${ANT_PATH}" ]; then
TOOLS_PATH="${TOOLS_PATH}${ANT_PATH}"
fi
if [ -n "${MVN_PATH}" ]; then
TOOLS_PATH="${TOOLS_PATH}${MVN_PATH}"
fi

print " - Adding shell profile PATH ${TOOLS_PATH}"
echo '# Java tools path
PATH="${PATH}'"${TOOLS_PATH}"'"
' > /etc/profile.d/java_tools.sh

print "Fixing startup scripts permissions"
cd /opt/bin && chmod uog+x mongo-start.sh mongo-stop.sh mysql-start.sh mysql-stop.sh

print "Configuring MySQL 8 yum repository"
echo '--------------------------------------------------------------------------------'
cd /tmp && yum -y localinstall '${mysql.pkg}'
yum -y module disable mysql

echo '--------------------------------------------------------------------------------'
print "Installing MySQL 8"
echo '--------------------------------------------------------------------------------'
yum -y install sudo mysql-community-server
groupmod -o -g "${JENKINS_GID}" mysql
usermod -o -g "${JENKINS_GID}" -u "${JENKINS_UID}" mysql
chown -v mysql:mysql /var/log/mysqld.log
chown -v -R mysql:mysql /var/lib/mysql-files /var/lib/mysql-keyring /var/run/mysqld
mysqld --initialize --user=mysql
echo '--------------------------------------------------------------------------------'
cat /var/log/mysqld.log
echo '--------------------------------------------------------------------------------'

print "Setting up MySQL 8 for tests"
echo '--------------------------------------------------------------------------------'
#Addtional permanent settings in configuration file
#To disable check for some stored functions
echo 'log_bin_trust_function_creators = 1
' >> /etc/my.cnf
/opt/bin/mysql-start.sh
ROOT_PWD=`cat /var/log/mysqld.log | grep 'A temporary password is generated for root' | sed -e 's/^.*localhost: *//'`
echo "
ALTER USER 'root'@'localhost' IDENTIFIED BY '${db.root.pwd}';
CREATE DATABASE ${mysql.database};
FLUSH PRIVILEGES;
" | mysql -v -u root --connect-expired-password --password="${ROOT_PWD}"
if [ '${db.user}' != 'root' ]; then
echo "
CREATE USER '${db.user}'@'localhost' IDENTIFIED BY '${db.pwd}';
GRANT ALL PRIVILEGES ON ${mysql.database}.* TO '${db.user}'@'localhost';
FLUSH PRIVILEGES;
" | mysql -v -u root --password='${db.root.pwd}'
fi
/opt/bin/mysql-stop.sh
echo '--------------------------------------------------------------------------------'

print "Configuring Mongo DB 3 yum repository"
echo '--------------------------------------------------------------------------------'
echo '[Mongodb]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/3.6/x86_64/
gpgcheck=0
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
' > /etc/yum.repos.d/mongodb.repo
chmod -v u=rw,og=r /etc/yum.repos.d/mongodb.repo
echo '--------------------------------------------------------------------------------'
print "Installing Mongo DB 3"
echo '--------------------------------------------------------------------------------'
yum install -y mongodb-org
groupmod -o -g "${JENKINS_GID}" mongod
usermod -o -g "${JENKINS_GID}" -u "${JENKINS_UID}" mongod
chown -v -R mongod:mongod /var/lib/mongo /var/log/mongodb /var/run/mongodb
echo '--------------------------------------------------------------------------------'
print "Post install cleanup"
echo '--------------------------------------------------------------------------------'
yum -y clean all
rm -vrf /var/cache/yum
Loading

0 comments on commit f772522

Please sign in to comment.