Skip to content

Commit f772522

Browse files
Tomáš KrausRadek Felcman
andauthored
New EclipseLik build image 2.0.0 with MySQL 8 (#1476)
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>
1 parent 3c40ddd commit f772522

File tree

13 files changed

+594
-13
lines changed

13 files changed

+594
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ target/
88
.idea/
99
test_*.properties
1010
.sonar
11+
*~

etc/el-test.mysql.properties

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
33
#
44
# This program and the accompanying materials are made available under the
55
# terms of the Eclipse Public License v. 2.0 which is available at
@@ -11,14 +11,16 @@
1111
#
1212

1313
# DB Connection properties
14-
db.driver=com.mysql.jdbc.Driver
15-
db.xa.driver=com.mysql.jdbc.Driver
14+
db.driver=com.mysql.cj.jdbc.Driver
15+
db.xa.driver=com.mysql.cj.jdbc.Driver
1616
#db.xa.driver=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
17-
db.url=jdbc:mysql://localhost:3306/ecltests?useSSL=false
17+
db.url=jdbc:mysql://localhost:3306/ecltests?allowPublicKeyRetrieval=true
18+
db.root.pwd=root
1819
db.user=root
1920
db.pwd=root
2021
db.platform=org.eclipse.persistence.platform.database.MySQLPlatform
21-
db.properties=url=jdbc:mysql://localhost:3306/ecltests;useSSL=false
22+
# Used in JEE server side tests to setup datasource by Maven Cargo plugin
23+
db.properties=url=jdbc:mysql://localhost:3306/ecltests?allowPublicKeyRetrieval=true
2224
#db.ddl.debug=true
2325
datasource.type=java.sql.Driver
2426
#datasource.type=javax.sql.XADataSource

etc/jenkins/build.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved.
2+
// Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
33
//
44
// This program and the accompanying materials are made available under the
55
// terms of the Eclipse Public License v. 2.0 which is available at
@@ -75,7 +75,7 @@ spec:
7575
requests:
7676
memory: "12Gi"
7777
cpu: "5.5"
78-
image: tkraus/el-build:1.1.9
78+
image: tkraus/el-build:2.0.0
7979
volumeMounts:
8080
- name: tools
8181
mountPath: /opt/tools
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
2+
3+
# This program and the accompanying materials are made available under the
4+
# terms of the Eclipse Public License v. 2.0 which is available at
5+
# http://www.eclipse.org/legal/epl-2.0,
6+
# or the Eclipse Distribution License v. 1.0 which is available at
7+
# http://www.eclipse.org/org/documents/edl-v10.php.
8+
9+
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
10+
11+
# Eclipse Foundation build infrastructure Docker image for EclipseLiunk builds
12+
FROM ${docker.source}
13+
14+
ADD ${java.pkg} ${ant.pkg} ${maven.pkg} ${install.java}/
15+
16+
ADD mongo-start.sh mongo-stop.sh mysql-start.sh mysql-stop.sh ${install.scripts}/
17+
18+
ADD install.sh ${mysql.pkg} /tmp/
19+
20+
RUN chmod u+x /tmp/install.sh \
21+
&& /tmp/install.sh > /tmp/install.log 2>&1 \
22+
&& rm -vf /tmp/install.sh /tmp/${mysql.pkg}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
4+
5+
# This program and the accompanying materials are made available under the
6+
# terms of the Eclipse Public License v. 2.0 which is available at
7+
# http://www.eclipse.org/legal/epl-2.0,
8+
# or the Eclipse Distribution License v. 1.0 which is available at
9+
# http://www.eclipse.org/org/documents/edl-v10.php.
10+
11+
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
12+
13+
# This script file is processed with Maven resource filtering
14+
# so variables expansion must be used with respect to defined
15+
# maven POM properties.
16+
17+
# Docker image installation file
18+
# Print timestamp and message to sdtout
19+
# Arguments:
20+
# $1 First message to be printed
21+
# $2 Second message to be printed
22+
# ...
23+
print() {
24+
echo '['`date '+%d.%m.%Y %H:%M:%S'`'] '$@
25+
}
26+
27+
JENKINS_USER='${build.user.name}'
28+
JENKINS_UID='${build.user.uid}'
29+
JENKINS_GROUP='${build.group.name}'
30+
JENKINS_GID='${build.group.gid}'
31+
32+
INSTALL_JAVA='${install.java}'
33+
34+
print "Adding Jenkins group ${JENKINS_GROUP}:${JENKINS_GID}"
35+
groupadd -g "${JENKINS_GID}" "${JENKINS_GROUP}"
36+
37+
print "Adding Jenkins user ${JENKINS_USER}:${JENKINS_UID}"
38+
useradd -u "${JENKINS_UID}" -g "${JENKINS_GID}" \
39+
-s '${build.user.shell}' -c '${build.user.comment}' \
40+
-m "${JENKINS_USER}"
41+
42+
print "Updating the system"
43+
echo '--------------------------------------------------------------------------------'
44+
yum -y update
45+
yum -y install git
46+
echo '--------------------------------------------------------------------------------'
47+
48+
print "Configuring Java tools in ${INSTALL_JAVA}"
49+
50+
JDK_PATH=''
51+
for i in `ls ${INSTALL_JAVA} | grep 'jdk-'`; do
52+
JDK_PATH="${JDK_PATH}:${INSTALL_JAVA}/${i}/bin"
53+
done
54+
print " - Open JDK ${JDK_PATH}"
55+
56+
ANT_PATH=''
57+
for i in `ls ${INSTALL_JAVA} | grep '\-ant-'`; do
58+
ANT_PATH="${ANT_PATH}:${INSTALL_JAVA}/${i}/bin"
59+
done
60+
print " - Apache Ant ${ANT_PATH}"
61+
62+
MVN_PATH=''
63+
for i in `ls ${INSTALL_JAVA} | grep '\-maven-'`; do
64+
MVN_PATH="${MVN_PATH}:${INSTALL_JAVA}/${i}/bin"
65+
done
66+
print " - Apache Maven ${MVN_PATH}"
67+
68+
if [ -n "${JDK_PATH}" ]; then
69+
TOOLS_PATH="${JDK_PATH}"
70+
else
71+
TOOLS_PATH=''
72+
fi
73+
if [ -n "${ANT_PATH}" ]; then
74+
TOOLS_PATH="${TOOLS_PATH}${ANT_PATH}"
75+
fi
76+
if [ -n "${MVN_PATH}" ]; then
77+
TOOLS_PATH="${TOOLS_PATH}${MVN_PATH}"
78+
fi
79+
80+
print " - Adding shell profile PATH ${TOOLS_PATH}"
81+
echo '# Java tools path
82+
PATH="${PATH}'"${TOOLS_PATH}"'"
83+
' > /etc/profile.d/java_tools.sh
84+
85+
print "Fixing startup scripts permissions"
86+
cd /opt/bin && chmod uog+x mongo-start.sh mongo-stop.sh mysql-start.sh mysql-stop.sh
87+
88+
print "Configuring MySQL 8 yum repository"
89+
echo '--------------------------------------------------------------------------------'
90+
cd /tmp && yum -y localinstall '${mysql.pkg}'
91+
yum -y module disable mysql
92+
93+
echo '--------------------------------------------------------------------------------'
94+
print "Installing MySQL 8"
95+
echo '--------------------------------------------------------------------------------'
96+
yum -y install sudo mysql-community-server
97+
groupmod -o -g "${JENKINS_GID}" mysql
98+
usermod -o -g "${JENKINS_GID}" -u "${JENKINS_UID}" mysql
99+
chown -v mysql:mysql /var/log/mysqld.log
100+
chown -v -R mysql:mysql /var/lib/mysql-files /var/lib/mysql-keyring /var/run/mysqld
101+
mysqld --initialize --user=mysql
102+
echo '--------------------------------------------------------------------------------'
103+
cat /var/log/mysqld.log
104+
echo '--------------------------------------------------------------------------------'
105+
106+
print "Setting up MySQL 8 for tests"
107+
echo '--------------------------------------------------------------------------------'
108+
#Addtional permanent settings in configuration file
109+
#To disable check for some stored functions
110+
echo 'log_bin_trust_function_creators = 1
111+
' >> /etc/my.cnf
112+
/opt/bin/mysql-start.sh
113+
ROOT_PWD=`cat /var/log/mysqld.log | grep 'A temporary password is generated for root' | sed -e 's/^.*localhost: *//'`
114+
echo "
115+
ALTER USER 'root'@'localhost' IDENTIFIED BY '${db.root.pwd}';
116+
CREATE DATABASE ${mysql.database};
117+
FLUSH PRIVILEGES;
118+
" | mysql -v -u root --connect-expired-password --password="${ROOT_PWD}"
119+
if [ '${db.user}' != 'root' ]; then
120+
echo "
121+
CREATE USER '${db.user}'@'localhost' IDENTIFIED BY '${db.pwd}';
122+
GRANT ALL PRIVILEGES ON ${mysql.database}.* TO '${db.user}'@'localhost';
123+
FLUSH PRIVILEGES;
124+
" | mysql -v -u root --password='${db.root.pwd}'
125+
fi
126+
/opt/bin/mysql-stop.sh
127+
echo '--------------------------------------------------------------------------------'
128+
129+
print "Configuring Mongo DB 3 yum repository"
130+
echo '--------------------------------------------------------------------------------'
131+
echo '[Mongodb]
132+
name=MongoDB Repository
133+
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/3.6/x86_64/
134+
gpgcheck=0
135+
enabled=1
136+
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
137+
' > /etc/yum.repos.d/mongodb.repo
138+
chmod -v u=rw,og=r /etc/yum.repos.d/mongodb.repo
139+
echo '--------------------------------------------------------------------------------'
140+
print "Installing Mongo DB 3"
141+
echo '--------------------------------------------------------------------------------'
142+
yum install -y mongodb-org
143+
groupmod -o -g "${JENKINS_GID}" mongod
144+
usermod -o -g "${JENKINS_GID}" -u "${JENKINS_UID}" mongod
145+
chown -v -R mongod:mongod /var/lib/mongo /var/log/mongodb /var/run/mongodb
146+
echo '--------------------------------------------------------------------------------'
147+
print "Post install cleanup"
148+
echo '--------------------------------------------------------------------------------'
149+
yum -y clean all
150+
rm -vrf /var/cache/yum

0 commit comments

Comments
 (0)