diff options
| author | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-09-30 09:50:57 +0200 |
|---|---|---|
| committer | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-09-30 09:52:27 +0200 |
| commit | 2cb0f61292ce13094b94b1c33c19e23736939376 (patch) | |
| tree | 68ef0ed8552ff787b365e4e1fc11373bd1a6eced | |
| parent | 8eadf3947a4d74a87e927abfaf9b5bcf7c9ec078 (diff) | |
| download | gn-machines-2cb0f61292ce13094b94b1c33c19e23736939376.tar.gz | |
cgit: README and drop experimental forge file
| -rw-r--r-- | genenetwork/services/cgit-README.md | 11 | ||||
| -rw-r--r-- | genenetwork/services/cgit-forge-container.scm | 225 |
2 files changed, 6 insertions, 230 deletions
diff --git a/genenetwork/services/cgit-README.md b/genenetwork/services/cgit-README.md index 221a4d8..c10b4f3 100644 --- a/genenetwork/services/cgit-README.md +++ b/genenetwork/services/cgit-README.md @@ -81,14 +81,15 @@ requests). The container shares the host network namespace (`--network`), so the container's ports are plain host ports: web 8883, ssh 2224. -Build: +Clone guix-bioinformatics, gn-machines and guix-forge repos in ~/guix/ + +Build using a recent version of guix: ```sh -cd factory guix system container --network \ - -L code/guix-bioinformatics -L code/gn-machines \ - -L code/contrib/guix-forge/guix \ - code/gn-machines/genenetwork/services/cgit-container.scm + -L ~/guix/guix-bioinformatics -L code/gn-machines \ + -L ~/guix/guix-forge/guix \ + ~/guix/gn-machines/genenetwork/services/cgit-container.scm ``` The three `-L` load paths are all required: `guix-bioinformatics` diff --git a/genenetwork/services/cgit-forge-container.scm b/genenetwork/services/cgit-forge-container.scm deleted file mode 100644 index e5ae51b..0000000 --- a/genenetwork/services/cgit-forge-container.scm +++ /dev/null @@ -1,225 +0,0 @@ -;;; genenetwork-machines --- Guix configuration for genenetwork machines -;;; Copyright © 2024 Pjotr Prins <pjotr.prins@thebird.nl> -;;; -;;; 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/>. - -;;; A cgit system container built DIRECTLY on the guix-forge services -;;; ((forge cgit), (forge fcgiwrap), (forge nginx), (forge anubis)), -;;; to test how far pure upstream reuse gets us inside a system -;;; container. Requires the guix-forge channel on the load path: -;;; -;;; guix system container --network \ -;;; -L factory/code/guix-bioinformatics \ -;;; -L factory/code/gn-machines \ -;;; -L factory/code/contrib/guix-forge \ -;;; factory/code/gn-machines/genenetwork/services/cgit-forge-container.scm -;;; -;;; Web interface on port 8882, ssh on 2223 with the pinned -;;; hello-container-key. A demo repository is seeded into /srv/git at -;;; first boot. KNOWN RISK: the stock nginx shepherd services (which -;;; forge-nginx extends) wedged container boots in earlier tests with -;;; BNW; this container exists to check whether that still holds. - -(define-module (genenetwork services cgit-forge-container) - #:use-module (gnu) - #:use-module ((forge cgit) #:select (cgit-configuration - cgit-service-type)) - #:use-module ((forge nginx) #:select (forge-nginx-configuration - forge-nginx-service-type - nginx-with-auth-request)) - #:use-module ((forge socket) #:select (forge-ip-socket)) - #: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-module (gnu packages version-control)) -(use-service-modules networking ssh web) -(use-package-modules base bash admin compression linux tls) - -;; Pinned SSH host key (from factory/code/run-guix-container/etc), so -;; every container presents the same host key and known_hosts does not -;; complain about a changed identification. -(define ssh-host-key (local-file - "../../../run-guix-container/etc/ssh-container-key" - "ssh_host_ecdsa_key")) -(define ssh-host-key.pub (local-file - "../../../run-guix-container/etc/ssh-container-key.pub" - "ssh_host_ecdsa_key.pub")) - -(define %demo-readme - (mixed-text-file "README.md" - "# Demo repository\n\n" - "This repository was seeded by the cgit container " - "activation so the web interface has something to " - "show. Hello from the cgit container!\n")) - -(operating-system - (host-name "cgit-forge-container") - (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)) - - (packages (list bash coreutils shadow grep procps git gzip)) - - (services - (append - (list - ;; The guix-forge cgit service: instantiates fcgiwrap (with the - ;; cgitrc passed through CGIT_CONFIG) and adds the nginx server - ;; block (including the git-http-backend smart HTTP location and - ;; Anubis protection for diff/tree URIs). - (service cgit-service-type - (cgit-configuration - (server-name "cgit-forge-container") - (repository-directory "/srv/git") - (fcgiwrap-processes 4))) - ;; forge-nginx renders the server blocks into the stock nginx - ;; service and instantiates Anubis. The stock nginx binary lacks - ;; the auth_request module that forge's cgit server block uses, - ;; so wire forge's nginx-with-auth-request build into the stock - ;; nginx service. - (service forge-nginx-service-type - (forge-nginx-configuration - (http-listen (forge-ip-socket (ip "0.0.0.0") (port 8882))))) - (service nginx-service-type - (nginx-configuration - (nginx nginx-with-auth-request))) - - ;; Password-less root login with hello-container-key. Host keys - ;; are pinned (see ssh-host-key above), not generated at boot. - (service openssh-service-type - (openssh-configuration - (port-number 2223) - (permit-root-login #t) - (password-authentication? #f) - (generate-host-keys? #f) - (authorized-keys - `(("root" ,(local-file - "../../../run-guix-container/etc/hello-container-key.pub" - "authorized_keys")))))) - - ;; Install the pinned ECDSA host key into /etc/ssh where sshd - ;; looks for it by default. - (simple-service 'container-ssh-host-key - activation-service-type - (with-imported-modules '((guix build utils)) - #~(begin - (use-modules (guix build utils)) - (mkdir-p "/etc/ssh") - (copy-file #$ssh-host-key - "/etc/ssh/ssh_host_ecdsa_key") - (chmod "/etc/ssh/ssh_host_ecdsa_key" #o600) - (copy-file #$ssh-host-key.pub - "/etc/ssh/ssh_host_ecdsa_key.pub") - (chmod "/etc/ssh/ssh_host_ecdsa_key.pub" #o644)))) - - ;; sshd needs the privilege separation directory /var/empty; on - ;; a full system it is created as the home directory of some - ;; system account, but a minimal container has none. - (simple-service 'container-var-empty - activation-service-type - (with-imported-modules '((guix build utils)) - #~(begin - (use-modules (guix build utils)) - (mkdir-p "/var/empty")))) - - ;; Seed a demo repository so cgit has something to show. - ;; cgit's scan-path expects BARE repositories (a non-bare repo - ;; is picked up as repo/.git), so build a temporary worktree - ;; repo and clone it bare into place. Git identity is passed - ;; with -c so no global config is needed, and the seeding is - ;; skipped when the repository already exists. - (simple-service 'cgit-demo-repository - activation-service-type - (with-imported-modules '((guix build utils)) - #~(begin - (use-modules (guix build utils)) - (define git-bin #$(file-append git "/bin/git")) - (mkdir-p "/srv/git") - (unless (file-exists? "/srv/git/demo/HEAD") - (let ((seed "/tmp/cgit-seed-demo")) - (mkdir-p seed) - (copy-file #$%demo-readme - (string-append seed "/README.md")) - (with-directory-excursion seed - (invoke git-bin "init" "-q" "-b" "main" ".") - (invoke git-bin "add" "README.md") - (invoke git-bin - "-c" "user.name=GeneNetwork Demo" - "-c" "user.email=demo@genenetwork.org" - "commit" "-q" - "-m" "Initial demo commit") - (invoke git-bin "clone" "-q" "--bare" - "." "/srv/git/demo"))) - (delete-file-recursively "/tmp/cgit-seed-demo"))))) - - ;; forge-nginx's HTTPS server block reads its certificate from - ;; /var/lib/acme/<server-name>/{cert.pem,private/key.pem}. The - ;; acme service is not instantiated in the container, so seed a - ;; self-signed certificate there at first boot. Without it - ;; 'nginx -t' fails and the nginx-init one-shot wedges the boot. - (simple-service 'container-self-signed-cert - activation-service-type - (with-imported-modules '((guix build utils)) - #~(begin - (use-modules (guix build utils)) - (unless (file-exists? - "/var/lib/acme/cgit-forge-container/cert.pem") - (mkdir-p - "/var/lib/acme/cgit-forge-container/private") - (invoke - #$(file-append openssl "/bin/openssl") - "req" "-x509" "-newkey" "rsa:2048" - "-keyout" - "/var/lib/acme/cgit-forge-container/private/key.pem" - "-out" - "/var/lib/acme/cgit-forge-container/cert.pem" - "-days" "3650" "-nodes" - "-subj" "/CN=cgit-forge-container"))))) - - ;; 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))))) |
