aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-09-02 17:28:52 +0530
committerArun Isaac2022-09-02 17:28:52 +0530
commit2a22204665065517ed1d14ec2fc12f25378f795b (patch)
treebe7d767381541194f70f4e2e3c6c7fe333f61b20
parent22e2e4887eea8b4ade6da7c72d46f91d74d643e5 (diff)
downloadgenenetwork2-2a22204665065517ed1d14ec2fc12f25378f795b.tar.gz
Add database container.
* containers/db-container.scm, containers/db-container.sh: New files.
-rw-r--r--containers/db-container.scm38
-rwxr-xr-xcontainers/db-container.sh12
2 files changed, 50 insertions, 0 deletions
diff --git a/containers/db-container.scm b/containers/db-container.scm
new file mode 100644
index 00000000..848b6a2e
--- /dev/null
+++ b/containers/db-container.scm
@@ -0,0 +1,38 @@
+;;; This file describes a Guix system container to run the database
+;;; services required by genenetwork2 locally on your own
+;;; machine. This is to allow a purely offline development setup for
+;;; hacking on genenetwork2. To build and run the container, use
+;;; db-container.sh.
+
+(use-modules (gnu)
+ (gnu packages databases)
+ (gnu services databases))
+
+(define %mariadb-state-directory
+ "/var/lib/mysql")
+
+(define set-permissions-gexp
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+
+ ;; Set ownership of mariadb state directory.
+ (let ((user (getpw "mysql")))
+ (for-each (lambda (file)
+ (chown file (passwd:uid user) (passwd:gid user)))
+ (find-files #$%mariadb-state-directory #:directories? #t))))))
+
+(operating-system
+ (host-name "genenetwork2")
+ (timezone "Etc/UTC")
+ (locale "en_US.utf8")
+ (bootloader (bootloader-configuration
+ (bootloader grub-bootloader)
+ (targets (list "does-not-matter"))))
+ (file-systems %base-file-systems)
+ (services (cons* (service mysql-service-type)
+ (service redis-service-type)
+ (simple-service 'set-permissions
+ activation-service-type
+ set-permissions-gexp)
+ %base-services)))
diff --git a/containers/db-container.sh b/containers/db-container.sh
new file mode 100755
index 00000000..bbe0247a
--- /dev/null
+++ b/containers/db-container.sh
@@ -0,0 +1,12 @@
+#! /bin/sh -e
+
+# Find path to containers directory.
+containers=$(dirname $0)
+
+# Create mariadb state directory if it does not exist.
+mkdir -p $containers/mariadb-state
+
+# Build the container.
+guix system container --network \
+ --share=$containers/mariadb-state=/var/lib/mysql \
+ $containers/db-container.scm