[libgda] Added Docker image for the Web provider
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Added Docker image for the Web provider
- Date: Sun, 13 Sep 2015 19:30:03 +0000 (UTC)
commit bd4ca7ed2c872e6546323de36e16796c07a42606
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Sep 13 21:29:24 2015 +0200
Added Docker image for the Web provider
docker-tools/web-test-server/Dockerfile | 12 +++
docker-tools/web-test-server/README | 19 +++++
docker-tools/web-test-server/build.sh | 8 ++
docker-tools/web-test-server/setup-data/.gitignore | 1 +
.../setup-data/gda-secure-config.php.tmpl | 33 ++++++++
docker-tools/web-test-server/setup-data/index.html | 58 +++++++++++++
docker-tools/web-test-server/setup-data/nginx.conf | 85 ++++++++++++++++++++
.../web-test-server/setup-data/phpinfo.php | 3 +
.../web-test-server/setup-scripts/install.sh | 18 ++++
docker-tools/web-test-server/setup-scripts/run.sh | 5 +
.../web-test-server/setup-scripts/update-cfg.sh | 6 ++
docker-tools/web-test-server/start.sh | 2 +
docker-tools/web-test-server/stop.sh | 2 +
13 files changed, 252 insertions(+), 0 deletions(-)
---
diff --git a/docker-tools/web-test-server/Dockerfile b/docker-tools/web-test-server/Dockerfile
new file mode 100644
index 0000000..a1c2f34
--- /dev/null
+++ b/docker-tools/web-test-server/Dockerfile
@@ -0,0 +1,12 @@
+FROM fedora:21
+
+MAINTAINER Vivien Malerba "vmalerba gmail com"
+ENV REFRESHED_AT 2014-11-23
+
+COPY setup-scripts/update-cfg.sh setup-scripts/install.sh setup-scripts/run.sh /
+COPY setup-data /setup-data
+RUN /install.sh
+
+EXPOSE 80
+
+CMD ["/run.sh"]
diff --git a/docker-tools/web-test-server/README b/docker-tools/web-test-server/README
new file mode 100644
index 0000000..2b6f604
--- /dev/null
+++ b/docker-tools/web-test-server/README
@@ -0,0 +1,19 @@
+Use the scripts contained here to create a Web server docker image which can be used
+to test Libgda's Web provider.
+
+* ./build.sh builds the docker image (named "libgda-test-web"). It does not create any database,
+ but declare connections to PostgreSQL and MySQL on the host (meant to connect to the corresponding
+ Docker containers)
+* ./start.sh starts a docker container in background
+* ./stop.sh stops a running docker container
+
+
+Parameters:
+-----------
+* master password: GdaSecret
+* connections' passwords: gdawebuser
+
+
+Web provider test:
+------------------
+Open Web page http://127.0.0.1, or direclty http://127.0.0.1/php/gda-tester.php
\ No newline at end of file
diff --git a/docker-tools/web-test-server/build.sh b/docker-tools/web-test-server/build.sh
new file mode 100755
index 0000000..bfe184a
--- /dev/null
+++ b/docker-tools/web-test-server/build.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# tar the php/ data
+phpdir=../../providers/web/php
+tar chf setup-data/php.tar $phpdir
+
+# actual build
+exec ../docker-tools.sh build Web
diff --git a/docker-tools/web-test-server/setup-data/.gitignore
b/docker-tools/web-test-server/setup-data/.gitignore
new file mode 100644
index 0000000..033752a
--- /dev/null
+++ b/docker-tools/web-test-server/setup-data/.gitignore
@@ -0,0 +1 @@
+php.tar
diff --git a/docker-tools/web-test-server/setup-data/gda-secure-config.php.tmpl
b/docker-tools/web-test-server/setup-data/gda-secure-config.php.tmpl
new file mode 100644
index 0000000..687ba37
--- /dev/null
+++ b/docker-tools/web-test-server/setup-data/gda-secure-config.php.tmpl
@@ -0,0 +1,33 @@
+<?php
+/*
+ * This file should be put outside the server's ROOT directory to avoid
+ * malicious accessing, for example in /etc.
+ *
+ * It is read only by the gda-config.php script.
+ */
+
+/*
+ * initial shared secret: will have to be passed as the SECRET argument when opening
+ * the connection from Libgda
+ */
+$init_shared = "GdaSecret";
+
+/*
+ * declared connections: for each connection which can be opened by Libgda, the
+ * the connection's password and the real connection's DSN need to be added respectively
+ * to the $cnc and $dsn arrays, using the connection name as a key. The connection name
+ * and password have no significance outside of the Libgda's context and be arbitrary.
+ * However the real connection's DSN need to be valid for the PEAR's MDB2 module, as
+ * per http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php
+ *
+ */
+
+/* PostgreSQL connection */
+$cnc["docker_postgresql"] = "gdawebuser";
+$dsn["docker_postgresql"] = "pgsql://gdauser:gdauser HOSTIP/gda";
+
+/* MySQL connection */
+$cnc["docker_mysql"] = "gdawebuser";
+$dsn["docker_mysql"] = "mysql://gdauser:gdauser HOSTIP/gda";
+
+?>
diff --git a/docker-tools/web-test-server/setup-data/index.html
b/docker-tools/web-test-server/setup-data/index.html
new file mode 100644
index 0000000..82d9a36
--- /dev/null
+++ b/docker-tools/web-test-server/setup-data/index.html
@@ -0,0 +1,58 @@
+<html>
+ <style media="screen" type="text/css">
+ body {
+ margin-top: 100px;
+ width: 70%;
+ margin-left: auto;
+ margin-right: auto;
+ }
+ </style>
+ <header>
+ <title>Libgda's Web test server</title>
+ </header>
+ <body>
+ <h1>Libgda's Web provider test server</h1>
+ <p>
+ This server is a test server for Libgda's "Web" provider, which provides access to databases
+ through a HTTP(S) connection.
+ </p>
+ <p>
+ <u>NB:</u>This server does not provide any security, it only serves testing purposes: it implements
+ HTTP only (HTTPS would require a certificate which is not easily automated);
+ for production environment, <b>NEVER</b> rely on a simple HTTP connection.
+ </p>
+ <div>
+ <h2>Server information</h2>
+ <p>
+ This instance of the Web provider is configured to allow connections to all of the other database
servers
+ for which there is a Docker images (ATM: PostgreSQL and MySQL):
+ <ul>
+ <li>The global secret is "GdaSecret"</li>
+ <li>Each connection's password is "gdawebuser".</li>
+ </ul>
+ The <a href="php/gda-tester.php">gda-tester.php</a> page shows all the available connections.
+ </p>
+ <p>
+ <u>NB:</u> if you can't get any connection to work, make sure you have started the corresponding
Docker
+ containers, and that the host's firewall does not prevent connections.
+ </p>
+ <p>Also check the <a href="phpinfo.php">phpinfo.php</a> script to see the server's PHP
configuration</p>
+ </div>
+
+ <div>
+ <h2>README for the GDA Web provider</h2>
+ <p>Unlike most other provider, this provider does not link to a database
+ specific library but rather acts as a web client for a web server
+ running some PHP scripts which acutally make the web server connect
+ to a database.</p>
+
+ <p>This provider enables a Libgda application to connect to a database
+ which is accessible only behind a web server (as many hosting databases
+ are) which can execute some PHP scripts and can connect to the
+ database. It is necessary to install some specific PHP scripts on the
+ web server which handle the connection and implement the protocol
+ described hereafter. Also the PHP interpreter need to be compiled with
+ the SimpleXML extension.</p>
+ </div>
+ </body>
+</html>
diff --git a/docker-tools/web-test-server/setup-data/nginx.conf
b/docker-tools/web-test-server/setup-data/nginx.conf
new file mode 100644
index 0000000..e855ea0
--- /dev/null
+++ b/docker-tools/web-test-server/setup-data/nginx.conf
@@ -0,0 +1,85 @@
+# For more information on configuration, see:
+# * Official English Documentation: http://nginx.org/en/docs/
+# * Official Russian Documentation: http://nginx.org/ru/docs/
+
+user nginx;
+worker_processes 4;
+
+error_log /var/log/nginx/error.log;
+#error_log /var/log/nginx/error.log notice;
+#error_log /var/log/nginx/error.log info;
+
+pid /run/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ '$status $body_bytes_sent "$http_referer" '
+ '"$http_user_agent" "$http_x_forwarded_for"';
+
+ access_log /var/log/nginx/access.log main;
+
+sendfile on;
+ #tcp_nopush on;
+
+ #keepalive_timeout 0;
+ keepalive_timeout 65;
+
+ #gzip on;
+
+ index index.html index.htm;
+
+ # Load modular configuration files from the /etc/nginx/conf.d directory.
+ # See http://nginx.org/en/docs/ngx_core_module.html#include
+ # for more information.
+ include /etc/nginx/conf.d/*.conf;
+
+ server {
+ listen 80 default_server;
+ server_name localhost;
+ root /usr/share/nginx/html;
+
+ #charset koi8-r;
+
+ #access_log /var/log/nginx/host.access.log main;
+
+ # Load configuration files for the default server block.
+ include /etc/nginx/default.d/*.conf;
+
+ location / {
+ }
+
+ # redirect server error pages to the static page /40x.html
+ #
+ error_page 404 /404.html;
+ location = /40x.html {
+ }
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ }
+
+ location ~ \.php$ {
+ root /usr/share/nginx/html;
+ try_files $uri =404;
+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
+ fastcgi_pass 127.0.0.1:9000;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ include fastcgi_params;
+ }
+ }
+}
+
+daemon off;
+
diff --git a/docker-tools/web-test-server/setup-data/phpinfo.php
b/docker-tools/web-test-server/setup-data/phpinfo.php
new file mode 100644
index 0000000..64b8a56
--- /dev/null
+++ b/docker-tools/web-test-server/setup-data/phpinfo.php
@@ -0,0 +1,3 @@
+<?php
+ phpinfo ();
+?>
\ No newline at end of file
diff --git a/docker-tools/web-test-server/setup-scripts/install.sh
b/docker-tools/web-test-server/setup-scripts/install.sh
new file mode 100755
index 0000000..cd5db78
--- /dev/null
+++ b/docker-tools/web-test-server/setup-scripts/install.sh
@@ -0,0 +1,18 @@
+echo "Running Upgrade..."
+yum -y -q upgrade
+echo "Installing packages..."
+yum -y install nginx php-pdo php-pear php-fpm php-pgsql php-mysql psmisc tar net-tools
+echo "Cleaning..."
+yum clean all
+
+cp /setup-data/nginx.conf /etc/nginx/
+cp /setup-data/index.html /usr/share/nginx/html/
+cp /setup-data/phpinfo.php /usr/share/nginx/html/
+pushd /usr/share/nginx/html && tar xf /setup-data/php.tar && mv providers/web/php . && rm -rf providers &&
popd
+
+pushd /usr/share/nginx/html/php/
+mv gda-config.php gda-config.php.orig && cat gda-config.php.orig | sed -e
's/\/\/set_include_path/set_include_path/' > gda-config.php
+mv gda-tester.php gda-tester.php.orig && cat gda-tester.php.orig | sed -e 's/test_connections =
false/test_connections = true/' > gda-tester.php
+
+mv /setup-data/gda-secure-config.php.tmpl .
+popd
diff --git a/docker-tools/web-test-server/setup-scripts/run.sh
b/docker-tools/web-test-server/setup-scripts/run.sh
new file mode 100755
index 0000000..421307b
--- /dev/null
+++ b/docker-tools/web-test-server/setup-scripts/run.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+/update-cfg.sh
+/usr/sbin/php-fpm -D
+/usr/sbin/nginx
diff --git a/docker-tools/web-test-server/setup-scripts/update-cfg.sh
b/docker-tools/web-test-server/setup-scripts/update-cfg.sh
new file mode 100755
index 0000000..7c19d0b
--- /dev/null
+++ b/docker-tools/web-test-server/setup-scripts/update-cfg.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+conf="/usr/share/nginx/html/php/gda-secure-config.php"
+hostip=`route -n | grep UG | awk '{print $2}'`
+
+cat ${conf}.tmpl | sed -e "s/HOSTIP/$hostip/g" > $conf
diff --git a/docker-tools/web-test-server/start.sh b/docker-tools/web-test-server/start.sh
new file mode 100755
index 0000000..6f6bb8d
--- /dev/null
+++ b/docker-tools/web-test-server/start.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec ../docker-tools.sh start Web
diff --git a/docker-tools/web-test-server/stop.sh b/docker-tools/web-test-server/stop.sh
new file mode 100755
index 0000000..6a3f3bd
--- /dev/null
+++ b/docker-tools/web-test-server/stop.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec ../docker-tools.sh stop Web
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]