;;; GeneCup system container for the run-guix-container daemon. #! The GeneCup services (genecup-service-type, genecup-nginx-service-type) live in (genenetwork services genecup) and are shared with a GeneCup VM; the genecup-gemini package definition lives in guix-bioinformatics/gn/packages/genecup.scm, pinned to commits of https://git.genenetwork.org/genecup. Build it with the three checkouts on the load path. Their layout varies per host, so pick BASE and FORGE first; -L must point at the directory that *contains* the module trees (forge/, gn/, genenetwork/): # checkouts side by side, guix-forge as a sub-checkout (factory) base=$HOME/guix; forge=$base/contrib/guix-forge/guix # ... or the same checkouts flat in one directory (e.g. balg01, # ~/services/genecup-service/{genecup,gn-machines, # guix-bioinformatics,guix-forge}) # base=$HOME/services/genecup-service; forge=$base/guix-forge/guix guix system container --network \ -L $base/guix-bioinformatics \ -L $base/gn-machines \ -L $forge \ $base/gn-machines/genenetwork/containers/genecup-container.scm A wrong -L does not say so: (genenetwork services genecup) fails to compile (its own (forge anubis) import is missing), the module then loads empty and guix reports only error: genecup-service-type: unbound variable so verify the paths before blaming the definition. With the right paths these must print the service types: guix repl -L $base/guix-bioinformatics -L $base/gn-machines -L $forge <<'EOF' (use-modules (genenetwork services genecup)) (display (list genecup-service-type genecup-nginx-service-type)) EOF Preferred on hosts running the run-guix-system-container daemon (listening on 127.0.0.1:8900, or 8989 on the reduced AI box): start the built container with run-guix-container.rb --daemon 127.0.0.1:8989 run-guix-container.rb --daemon 127.0.0.1:8989 --log Inspect over ssh on port 2223 with the pinned ~/hello-container-key, or check the web server on port 4201 (nginx, proxying to the Flask app on 127.0.0.1:4202). The web UI can be protected by the Anubis AI-bot firewall (anubis? #t on the genecup-nginx-configuration). The Flask app keeps its writable state (userspub.sqlite, per-user folders) in /var/lib/genecup. Optional local PubMed archive: add --share=/export3/PubMed=/export3/PubMed to the 'guix system container' invocation and set the pubmed-archive field to "/export3/PubMed/Source" -- otherwise edirect queries NCBI over the network. The Gemini API key is read by the app from ~/.config/gemini/credentials of the 'genecup' user, i.e. /var/lib/genecup/.config/gemini/credentials, mode 0400 (the app exits when the mode is anything else). Expose the host's key read-only and let the genecup activation copy it into place with the right owner and mode -- a secret must not go into the store: --expose=$HOME/.config/gemini/credentials=/run/secrets/gemini-credentials Without it GeneCup still runs; only the LLM synthesis features are disabled. Either way the one-shot 'gemini-check' shepherd service reports at boot whether the key is present and whether the API accepts it ("Gemini classification available"/"... not available: ") to the boot log and /var/log/gemini-check.log. !# (define-module (genenetwork containers genecup-container) #:use-module (gnu) #:use-module (genenetwork services genecup) #:use-module (genenetwork packages) #:use-module (genenetwork services nginx) #:use-module (gnu services web) #:use-module (genenetwork services container-ssh) #:use-module (guix gexp) #:use-module (guix build utils) #:use-module (gnu services base) #:use-module (gnu services shepherd) #:use-module (gnu services sysctl)) (use-package-modules base bash admin linux) ;; The pinned SSH keys live in the building user's $HOME and are ;; fetched from there at build time; container-ssh-service (shared ;; with the other containers) wires them into sshd. See the Keys ;; section of genenetwork/containers/cgit-container.scm. ;; What this container is, said once. A store path is a hash and a pid says ;; nothing; this string is the OS's issue field and the ssh banner, and the ;; shared container-ssh-service also prints it as the first line of the boot log. (define %genecup-banner "genecup-container -- GeneNetwork genecup (web :4201, ssh :2223)\nThis is a container, not the host. Exit the shell and you are back on the\nhost; the definition is gn-machines/genenetwork/containers/genecup-container.scm.\n") (operating-system (host-name "genecup-container") (issue %genecup-banner) (timezone "Etc/UTC") (locale "en_US.utf8") (bootloader (bootloader-configuration (bootloader grub-bootloader) (targets '("/dev/sdX")))) (file-systems (cons (file-system (device (file-system-label "does-not-matter")) (mount-point "/") (type "ext4")) %base-file-systems)) ;; Run PID 1 with the self-pipe signal variant: see ;; shepherd-for-containers in (genenetwork packages). Everything ;; else about the system's shepherd is the stock one. (essential-services (modify-services (operating-system-default-essential-services this-operating-system) (shepherd-root-service-type config => (shepherd-configuration (inherit config) (shepherd shepherd-for-containers))))) ;; Minimal package set: the genecup package (with its Python ;; closure, edirect and minipubmed) comes in through the services, ;; ssh tools through the openssh service and 'herd' through the ;; essential shepherd service. (packages (list bash coreutils shadow grep procps)) (services (append (list ;; The stock nginx front-end; genecup-nginx-service-type below ;; contributes its nginx-server-configuration sites to it. ;; Larger searches post sizeable ontologies; stay safe. (service nginx-service-type (nginx-configuration (extra-content (list (client-max-body-size "32m"))))) (service genecup-service-type (genecup-configuration ;; Exposed read-only by the launcher (see the --expose ;; flag in the header); the activation copies it to ;; /var/lib/genecup/.config/gemini/credentials (0400). (gemini-credentials "/run/secrets/gemini-credentials"))) (service genecup-nginx-service-type (genecup-nginx-configuration (port "4201") (app-port "4202") ;; Production runs behind a TLS-terminating proxy and ;; keeps Secure cookies; set to #f for plain-HTTP test ;; deployments (see bnw-container.scm). (anubis? #t) (anubis-cookie-secure? #f)))) ; TEMP test ;; SSH on port 2223 (BNW uses 2222, cgit 2224): password-less root ;; login with hello-container-key, the pinned ECDSA host key (not ;; generated at boot) and the /var/empty fix -- all shared with the ;; other containers via container-ssh-service. (container-ssh-service #:port-number 2223 #:banner %genecup-banner) (list ;; In a container sysctl (writes /proc/sys) and udev (coldplug on ;; the static /dev the container runtime sets up) are useless and ;; their start-up hangs the whole boot: urandom-seed requires ;; udev, user-processes requires urandom-seed, and ssh-daemon ;; requires user-processes. Provide no-ops instead. (simple-service 'container-sysctl shepherd-root-service-type (list (shepherd-service (provision '(sysctl)) (one-shot? #t) (start #~(const #t))))) (simple-service 'container-udev shepherd-root-service-type (list (shepherd-service (provision '(udev)) (one-shot? #t) (start #~(const #t)))))) (modify-services %base-services ;; Drop the guix service: its activation runs 'guix archive ;; --generate-key' at every boot, which stalls the container ;; boot; a minimal container does not need guix-daemon anyway. (delete guix-service-type) (delete sysctl-service-type) (delete udev-service-type)))))