about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-04-10 07:09:43 +0300
committerFrederick Muriuki Muriithi2024-05-05 07:30:42 +0300
commit735deacbe994fb4ac20e2745b40d1bd976c26037 (patch)
tree69c2a770f3c79d31aa0ac0ca324eb5e7326035dd
parent7e2d03f4f2534c94589ae723a331e39b30a1b818 (diff)
downloadgn-machines-735deacbe994fb4ac20e2745b40d1bd976c26037.tar.gz
gn-uploader: Serve static files via nginx. gn-uploader-nginx-static-files
-rw-r--r--genenetwork/services/genenetwork.scm28
1 files changed, 27 insertions, 1 deletions
diff --git a/genenetwork/services/genenetwork.scm b/genenetwork/services/genenetwork.scm
index b13d006..c25caf0 100644
--- a/genenetwork/services/genenetwork.scm
+++ b/genenetwork/services/genenetwork.scm
@@ -21,7 +21,9 @@
 
 (define-module (genenetwork services genenetwork)
   #:use-module ((gn packages genenetwork) #:select (genenetwork2 genenetwork3 gn-auth gn-uploader))
+  #:use-module ((gnu packages web) #:select (nginx))
   #:use-module ((gnu packages admin) #:select (shadow))
+  #:use-module ((gnu packages python) #:select (python-3))
   #:use-module (gnu services)
   #:use-module (gnu services web)
   #:use-module (gnu system file-systems)
@@ -29,6 +31,10 @@
   #:use-module (guix gexp)
   #:use-module (guix profiles)
   #:use-module (guix records)
+  #:use-module (guix store)
+  #:use-module (guix derivations)
+  #:use-module (guix packages)
+  #:use-module (guix build python-build-system)
   #:use-module (forge environment)
   #:use-module (forge nginx)
   #:use-module (forge gunicorn)
@@ -449,13 +455,33 @@ a @code{<genenetwork-configuration>} record."
                               (writable? #t))))
              (extra-cli-arguments (list "--log-level" log-level)))))))
 
+(define (package-output-path package)
+  "Return the computed store output path for `PACKAGE'."
+  (derivation-output-path
+   (assoc-ref
+    (derivation-outputs
+     (with-store %store
+       (run-with-store %store
+         (lower-object package)))) "out")))
+
 (define (gn-uploader-nginx-server-block config)
   (match-record config <gn-uploader-configuration>
-   (server-name port)
+   (server-name port gn-uploader)
     (list (nginx-server-configuration
            (server-name (list server-name))
            (locations
             (list (nginx-location-configuration
+                   (uri "/static")
+                   (body
+                    (list
+                     #~(string-append "include "
+                                      #$(file-append nginx "/share/nginx/conf/mime.types;"))
+                     #~(string-append "root "
+                                      #$(file-append gn-uploader
+                                                     "/lib/python"
+                                                     (python-version (package-version python-3))
+                                                     "/site-packages/qc_app;")))))
+                  (nginx-location-configuration
                    (uri "/")
                    (body (list (string-append "proxy_pass http://localhost:"
                                               (number->string port) ";")