[libgda] Added script to build MySQL server using docker
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Added script to build MySQL server using docker
- Date: Sun, 4 Jan 2015 16:10:07 +0000 (UTC)
commit 37a368eb4014ed81d4f22074d4658084c3d8bf2f
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Jan 4 16:56:44 2015 +0100
Added script to build MySQL server using docker
docker-tools/mysql-test-server/Dockerfile | 12 +++++++
docker-tools/mysql-test-server/README | 21 ++++++++++++
docker-tools/mysql-test-server/build.sh | 33 ++++++++++++++++++++
docker-tools/mysql-test-server/install.sh | 10 ++++++
docker-tools/mysql-test-server/run.sh | 4 ++
.../mysql-test-server/setup-data/.gitignore | 2 +
.../mysql-test-server/setup-data/mysql-setup | 8 +++++
.../mysql-test-server/setup-data/setup-data.sh | 14 ++++++++
docker-tools/mysql-test-server/setup-data/user.sql | 7 ++++
docker-tools/mysql-test-server/start.sh | 20 ++++++++++++
10 files changed, 131 insertions(+), 0 deletions(-)
---
diff --git a/docker-tools/mysql-test-server/Dockerfile b/docker-tools/mysql-test-server/Dockerfile
new file mode 100644
index 0000000..3dae33a
--- /dev/null
+++ b/docker-tools/mysql-test-server/Dockerfile
@@ -0,0 +1,12 @@
+FROM fedora:21
+
+MAINTAINER Vivien Malerba "vmalerba gmail com"
+ENV REFRESHED_AT 2015-01-04
+
+COPY install.sh run.sh /
+COPY setup-data /setup-data
+RUN /install.sh
+
+EXPOSE 3306
+
+CMD ["/run.sh"]
diff --git a/docker-tools/mysql-test-server/README b/docker-tools/mysql-test-server/README
new file mode 100644
index 0000000..0750663
--- /dev/null
+++ b/docker-tools/mysql-test-server/README
@@ -0,0 +1,21 @@
+Use the scripts contained here to create a MySQL server docker image which can be used
+to test Libgda's MySQL provider.
+
+* build.sh builds the docker image (named "libgda-test-mysql"). It creates a database populated with
+ data from the NorthWind database (https://code.google.com/p/northwindextended/).
+
+* start.sh starts a docker container from the built image, stop it using CTRL-C
+
+
+Parameters:
+-----------
+* created database name: gda
+* created user name/pass: root/gdauser (can only log from docker's localhost)
+* created user name/pass: gdauser/gdauser (can only log from any host, incl. docker's localhost)
+
+
+MySQL test:
+----------------
+$ mysql -h 127.0.0.1 -u gdauser --password=gdauser gda
+
+$ gda-sql-6.0 "MySQL://gdauser:gdauser HOST=127 0 0 1;DB_NAME=gda"
\ No newline at end of file
diff --git a/docker-tools/mysql-test-server/build.sh b/docker-tools/mysql-test-server/build.sh
new file mode 100755
index 0000000..54f7cd1
--- /dev/null
+++ b/docker-tools/mysql-test-server/build.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+#docker_cmd="sudo docker"
+docker_cmd="docker"
+image_name="libgda-test-mysql"
+
+# test docker install
+$docker_cmd version > /dev/null 2>&1 || {
+ echo "Can't find or execute docker"
+ exit 1
+}
+
+# download Northwind data if necessary
+sqlfile=setup-data/northwind.sql
+if [ ! -e $sqlfile ]
+then
+ echo "Missing $sqlfile, downloading (about 0.8 Mb)..."
+ file="https://people.gnome.org/~vivien/northwind_mysql_01.sql"
+ wget -q $file > /dev/null 2>&1 || {
+ echo "Unable to get $file, check with Libgda's maintainer!"
+ exit 1
+ }
+ mv norhtwind_mysql_01.sql $sqlfile
+ echo "Download complete"
+fi
+
+echo "Now building Docker image, this will take a few minutes (or maybe half an hour, depending on you
setup)..."
+$docker_cmd build --force-rm -q -t "$image_name" . || {
+ echo "Failed to build image."
+ exit 1
+}
+echo "Image '$image_name' is now ready, you can use the start.sh script"
+
diff --git a/docker-tools/mysql-test-server/install.sh b/docker-tools/mysql-test-server/install.sh
new file mode 100755
index 0000000..d7a6f27
--- /dev/null
+++ b/docker-tools/mysql-test-server/install.sh
@@ -0,0 +1,10 @@
+echo "Running Upgrade..."
+yum -y -q upgrade
+echo "Installing packages..."
+yum -y install community-mysql-server
+echo "Cleaning..."
+yum clean all
+
+echo "Server setup"
+/setup-data/mysql-setup
+/setup-data/setup-data.sh
diff --git a/docker-tools/mysql-test-server/run.sh b/docker-tools/mysql-test-server/run.sh
new file mode 100755
index 0000000..f594096
--- /dev/null
+++ b/docker-tools/mysql-test-server/run.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+exec /usr/bin/mysqld_safe --explicit_defaults_for_timestamp
+
diff --git a/docker-tools/mysql-test-server/setup-data/.gitignore
b/docker-tools/mysql-test-server/setup-data/.gitignore
new file mode 100644
index 0000000..0c3f2b4
--- /dev/null
+++ b/docker-tools/mysql-test-server/setup-data/.gitignore
@@ -0,0 +1,2 @@
+northwind.sql
+
diff --git a/docker-tools/mysql-test-server/setup-data/mysql-setup
b/docker-tools/mysql-test-server/setup-data/mysql-setup
new file mode 100755
index 0000000..72868d9
--- /dev/null
+++ b/docker-tools/mysql-test-server/setup-data/mysql-setup
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+mysql_install_db --user=mysql --explicit_defaults_for_timestamp
+/usr/bin/mysqld_safe --explicit_defaults_for_timestamp &
+echo "Let's give the server some time to start..."
+sleep 5
+echo "Now continue."
+
diff --git a/docker-tools/mysql-test-server/setup-data/setup-data.sh
b/docker-tools/mysql-test-server/setup-data/setup-data.sh
new file mode 100755
index 0000000..b7879be
--- /dev/null
+++ b/docker-tools/mysql-test-server/setup-data/setup-data.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+cd /setup-data
+
+password="gdauser"
+
+/usr/bin/mysqladmin -u root password "$password"
+cat user.sql | sed -e "s/PASSWORD/$password/" | /usr/bin/mysql -u root --password=$password
+
+# loading data
+/usr/bin/mysql -u gdauser --password=$password < northwind.sql
+
+# shutdown server
+/usr/bin/mysqladmin -u root --password=$password shutdown
diff --git a/docker-tools/mysql-test-server/setup-data/user.sql
b/docker-tools/mysql-test-server/setup-data/user.sql
new file mode 100644
index 0000000..7dc8f2e
--- /dev/null
+++ b/docker-tools/mysql-test-server/setup-data/user.sql
@@ -0,0 +1,7 @@
+# select host, user from mysql.user;
+
+CREATE USER 'gdauser'@'%' IDENTIFIED BY 'PASSWORD';
+GRANT ALL PRIVILEGES ON * . * TO 'gdauser'@'%';
+CREATE USER 'gdauser'@'localhost' IDENTIFIED BY 'PASSWORD';
+GRANT ALL PRIVILEGES ON * . * TO 'gdauser'@'localhost';
+FLUSH PRIVILEGES;
diff --git a/docker-tools/mysql-test-server/start.sh b/docker-tools/mysql-test-server/start.sh
new file mode 100755
index 0000000..b92cfda
--- /dev/null
+++ b/docker-tools/mysql-test-server/start.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+image_name="libgda-test-mysql"
+
+# test docker install
+docker version > /dev/null 2>&1 || {
+ echo "Can't find or execute docker"
+ exit 1
+}
+
+# test docker image
+img=`docker images -q "$image_name"`
+if test "x$img" == "x"
+then
+ echo "The docker image '$image_name' is not present, use the ./build.sh script first"
+ exit 1
+fi
+
+echo "Running MySQL server, hit CTRL-C to stop"
+docker run -t -i -p 3306:3306 --rm --name test-mysql "$image_name"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]