aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-11-07 19:55:07 +0530
committerArun Isaac2022-11-07 19:55:07 +0530
commit3cebfb3e30e903851aefb2f997d8847d3f0ddee4 (patch)
tree06b9c8d690c064f01e8fefab2c1c14d7d5da146f
parentdfa338e353ec3305cfcf801149920a819f4ff335 (diff)
downloadgn-machines-3cebfb3e30e903851aefb2f997d8847d3f0ddee4.tar.gz
Add public facing SPARQL container.
* public-sparql-deploy.sh, public-sparql.scm: New files.
-rwxr-xr-xpublic-sparql-deploy.sh30
-rw-r--r--public-sparql.scm62
2 files changed, 92 insertions, 0 deletions
diff --git a/public-sparql-deploy.sh b/public-sparql-deploy.sh
new file mode 100755
index 0000000..685de28
--- /dev/null
+++ b/public-sparql-deploy.sh
@@ -0,0 +1,30 @@
+#! /bin/sh -e
+
+# genenetwork-machines --- Guix configuration for genenetwork machines
+# Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+#
+# This file is part of genenetwork-machines.
+#
+# genenetwork-machines is free software: you can redistribute it
+# and/or modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# genenetwork-machines is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with genenetwork-machines. If not, see
+# <https://www.gnu.org/licenses/>.
+
+container_script=$(guix system container \
+ --network \
+ --verbosity=3 \
+ --share=/var/guix-containers/public-sparql/var/lib/mysql=/var/lib/mysql \
+ --share=/var/guix-containers/public-sparql/var/lib/virtuoso=/var/lib/virtuoso \
+ public-sparql.scm)
+
+echo $container_script
+sudo ln --force --symbolic $container_script /usr/local/bin/public-sparql-container
diff --git a/public-sparql.scm b/public-sparql.scm
new file mode 100644
index 0000000..500fbdb
--- /dev/null
+++ b/public-sparql.scm
@@ -0,0 +1,62 @@
+;;; genenetwork-machines --- Guix configuration for genenetwork machines
+;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of genenetwork-machines.
+;;;
+;;; genenetwork-machines is free software: you can redistribute it
+;;; and/or modify it under the terms of the GNU General Public License
+;;; as published by the Free Software Foundation, either version 3 of
+;;; the License, or (at your option) any later version.
+;;;
+;;; genenetwork-machines is distributed in the hope that it will be
+;;; useful, but WITHOUT ANY WARRANTY; without even the implied
+;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+;;; See the GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with genenetwork-machines. If not, see
+;;; <https://www.gnu.org/licenses/>.
+
+(use-modules (gnu)
+ (gn services databases)
+ (gnu services web))
+
+(define (virtuoso-reverse-proxy-server-block listen sparql-port)
+ "Return an <nginx-server-configuration> object listening on LISTEN to
+reverse proxy the Virtuoso server. SPARQL-PORT is the port virtuoso's
+SPARQL endpoint is listening on."
+ (nginx-server-configuration
+ (server-name '("sparql.genenetwork.org"))
+ (listen (list listen))
+ (locations
+ (list (nginx-location-configuration
+ (uri "/")
+ (body (list (string-append "proxy_pass http://localhost:"
+ (number->string sparql-port) ";")
+ "proxy_set_header Host $host;")))))))
+
+(define %reverse-proxy-port 8990)
+(define %virtuoso-port 8981)
+(define %sparql-port 8982)
+
+(operating-system
+ (host-name "sparql")
+ (timezone "UTC")
+ (locale "en_US.utf8")
+ (bootloader (bootloader-configuration
+ (bootloader grub-bootloader)
+ (targets (list "/dev/sdX"))))
+ (file-systems %base-file-systems)
+ (users %base-user-accounts)
+ (packages %base-packages)
+ (services (cons* (service virtuoso-service-type
+ (virtuoso-configuration
+ (server-port %virtuoso-port)
+ (http-server-port %sparql-port)))
+ (service nginx-service-type
+ (nginx-configuration
+ (server-blocks
+ (list (virtuoso-reverse-proxy-server-block
+ (number->string %reverse-proxy-port)
+ %sparql-port)))))
+ %base-services)))