Combining webservers into one container. - selfhost - Incus configurations for my self-hosted setup.
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit 1f2016feeb6d8fbc28b24c39098371421b0218dd
 (DIR) parent e1923390fc7e1b1c48e67e4277f2ebafb49b8499
 (HTM) Author: Jay Scott <me@jay.scot>
       Date:   Tue,  9 Jul 2024 23:44:17 +0100
       
       Combining webservers into one container.
       
       Diffstat:
         D config.yaml                         |      24 ------------------------
         D dashboard/dashboard.yaml            |      53 ------------------------------
         D dashboard/init.sh                   |       8 --------
         D docs/docs.yaml                      |      29 -----------------------------
         D docs/files/lighttpd.conf            |      29 -----------------------------
         D docs/init.sh                        |      12 ------------
         D git/files/lighttpd.conf             |      29 -----------------------------
         A git/files/sealgit                   |       0 
         A git/files/stagit                    |       0 
         M git/files/stagit.sh                 |       2 +-
         A git/files/templates/index.html      |      34 +++++++++++++++++++++++++++++++
         M git/git.yaml                        |       8 ++++----
         M git/init.sh                         |      12 +++---------
         M sfeed/files/fetch.sh                |       1 -
         D sfeed/files/lighttpd.conf           |      29 -----------------------------
         D sfeed/files/style.css               |      15 ---------------
         M sfeed/init.sh                       |       4 ----
         M sfeed/sfeed.yaml                    |      10 +++++-----
         A static/init.sh                      |       8 ++++++++
         A static/static.yaml                  |      81 ++++++++++++++++++++++++++++++
       
       20 files changed, 136 insertions(+), 252 deletions(-)
       ---
 (DIR) diff --git a/config.yaml b/config.yaml
       @@ -1,24 +0,0 @@
       -config:
       -  cloud-init.network-config: |
       -    version: 2
       -    ethernets:
       -      eth0:
       -        addresses:
       -          - 192.168.2.10/24
       -        gateway4: 192.168.2.1
       -  cloud-init.user-data: |
       -    #cloud-config
       -    manage_resolv_conf: true
       -    resolv_conf:
       -      nameservers: ['192.168.2.197', '1.1.1.1']
       -    package_upgrade: true
       -    timezone: Europe/London
       -    users:
       -      - name: jay
       -        groups: wheel
       -        ssh_authorized_keys:
       -          - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDLmKYxwXTbyRWLG0S24RTpyfyBO6AL8Dcy0XvVZ97Do
       -    packages:
       -      - git
       -      - curl
       -      - coredns
 (DIR) diff --git a/dashboard/dashboard.yaml b/dashboard/dashboard.yaml
       @@ -1,53 +0,0 @@
       -devices:
       -  htdocs:
       -    path: /srv/www
       -    source: /srv/services/dashboard
       -    type: disk
       -  certs:
       -    path: /etc/lighttpd/certs
       -    source: /srv/certs
       -    type: disk
       -    shift: true
       -
       -config:
       -  cloud-init.network-config: |
       -    version: 2
       -    ethernets:
       -      eth0:
       -        addresses:
       -          - 192.168.2.11/24
       -        gateway4: 192.168.2.1
       -  cloud-init.user-data: |
       -    #cloud-config
       -    package_upgrade: true
       -    hostname: dashboard.jay.scot
       -    timezone: Europe/London
       -    manage_resolv_conf: true
       -    resolv_conf:
       -      nameservers: ['192.168.2.10', '1.1.1.1']
       -    packages:
       -      - lighttpd
       -    runcmd:
       -      - rc-service lighttpd start
       -    write_files:
       -      - path: /etc/lighttpd/lighttpd.conf
       -        defer: true
       -        append: true
       -        content: |
       -
       -          server.modules += ( "mod_redirect", "mod_openssl")
       -          $SERVER["socket"] == ":443" {
       -              ssl.engine  = "enable"
       -              ssl.pemfile = "/etc/lighttpd/certs/jay.scot.cer"
       -              ssl.privkey = "/etc/lighttpd/certs/jay.scot.key"
       -              ssl.openssl.ssl-conf-cmd = ("MinProtocol" => "TLSv1.3", "Options" => "-ServerPreference")
       -
       -              server.name          = "dashboard.jay.scot"
       -              server.document-root = "/srv/www/"
       -          }
       -
       -          $HTTP["scheme"] == "http" {
       -              $HTTP["host"] =~ ".*" {
       -                  url.redirect = (".*" => "https://%0$0")
       -              }
       -          }
 (DIR) diff --git a/dashboard/init.sh b/dashboard/init.sh
       @@ -1,8 +0,0 @@
       -#!/bin/sh
       -
       -HOST=dashboard
       -
       -incus stop $HOST
       -incus delete $HOST
       -incus launch images:alpine/3.20/cloud $HOST < $HOST.yaml
       -
 (DIR) diff --git a/docs/docs.yaml b/docs/docs.yaml
       @@ -1,29 +0,0 @@
       -devices:
       -  htdocs:
       -    path: /srv/www
       -    source: /srv/services/docs
       -    type: disk
       -  certs:
       -    path: /etc/lighttpd/certs
       -    source: /srv/certs
       -    type: disk
       -    shift: true
       -
       -config:
       -  cloud-init.network-config: |
       -    version: 2
       -    ethernets:
       -      eth0:
       -        addresses:
       -          - 192.168.2.13/24
       -        gateway4: 192.168.2.1
       -  cloud-init.user-data: |
       -    #cloud-config
       -    package_upgrade: true
       -    hostname: docs.jay.scot
       -    timezone: Europe/London
       -    manage_resolv_conf: true
       -    resolv_conf:
       -      nameservers: ['192.168.2.10', '1.1.1.1']
       -    packages:
       -      - lighttpd
 (DIR) diff --git a/docs/files/lighttpd.conf b/docs/files/lighttpd.conf
       @@ -1,29 +0,0 @@
       -var.basedir  = "/var/www/localhost"
       -var.logdir   = "/var/log/lighttpd"
       -var.statedir = "/var/lib/lighttpd"
       -
       -include "mime-types.conf"
       -server.username      = "lighttpd"
       -server.groupname     = "lighttpd"
       -server.document-root = var.basedir + "/htdocs"
       -server.pid-file      = "/run/lighttpd.pid"
       -server.errorlog      = var.logdir  + "/error.log"
       -index-file.names     = ("index.html")
       -
       -server.modules += ( "mod_redirect", "mod_openssl")
       -
       -$SERVER["socket"] == ":443" {
       -    ssl.engine  = "enable"
       -    ssl.pemfile = "/etc/lighttpd/certs/jay.scot.cer"
       -    ssl.privkey = "/etc/lighttpd/certs/jay.scot.key"
       -    ssl.openssl.ssl-conf-cmd = ("MinProtocol" => "TLSv1.3", "Options" => "-ServerPreference")
       -
       -    server.name          = "dashboard.jay.scot"
       -    server.document-root = "/srv/www/"
       -}
       -
       -$HTTP["scheme"] == "http" {
       -    $HTTP["host"] =~ ".*" {
       -        url.redirect = (".*" => "https://%0$0")
       -    }
       -}
 (DIR) diff --git a/docs/init.sh b/docs/init.sh
       @@ -1,12 +0,0 @@
       -#!/bin/sh
       -
       -HOST=docs
       -
       -incus stop $HOST
       -incus delete $HOST
       -incus launch images:alpine/3.20/cloud $HOST < $HOST.yaml
       -
       -incus file push ./files/lighttpd.conf $HOST/etc/lighttpd/ -pv --mode 644
       -incus exec $HOST -- cloud-init status --wait
       -incus exec $HOST -- rc-service lighttpd start
       -
 (DIR) diff --git a/git/files/lighttpd.conf b/git/files/lighttpd.conf
       @@ -1,29 +0,0 @@
       -var.basedir  = "/var/www/localhost"
       -var.logdir   = "/var/log/lighttpd"
       -var.statedir = "/var/lib/lighttpd"
       -
       -include "mime-types.conf"
       -server.username      = "lighttpd"
       -server.groupname     = "lighttpd"
       -server.document-root = var.basedir + "/htdocs"
       -server.pid-file      = "/run/lighttpd.pid"
       -server.errorlog      = var.logdir  + "/error.log"
       -index-file.names     = ("index.html")
       -
       -server.modules += ( "mod_cgi", "mod_rewrite", "mod_openssl")
       -
       -$SERVER["socket"] == ":443" {
       -    ssl.engine  = "enable"
       -    ssl.pemfile = "/etc/lighttpd/certs/jay.scot.cer"
       -    ssl.privkey = "/etc/lighttpd/certs/jay.scot.key"
       -    ssl.openssl.ssl-conf-cmd = ("MinProtocol" => "TLSv1.3", "Options" => "-ServerPreference")
       -
       -    server.name          = "git.jay.scot"
       -    server.document-root = "/srv/www/"
       -}
       -
       -$HTTP["scheme"] == "http" {
       -    $HTTP["host"] =~ ".*" {
       -        url.redirect = (".*" => "https://%0$0")
       -    }
       -}
 (DIR) diff --git a/git/files/sealgit b/git/files/sealgit
       Binary files differ.
 (DIR) diff --git a/git/files/stagit b/git/files/stagit
       Binary files differ.
 (DIR) diff --git a/git/files/stagit.sh b/git/files/stagit.sh
       @@ -4,7 +4,7 @@ reposdir="/srv/git"
        wwwdir="/srv/www"
        
        #stagit-index "${reposdir}/"*/ | sed 's|/log\.html||g' > "${wwwdir}/index.html"
       -gostag -p /srv/git/ -g > "${wwwdir}/index.html" 
       +sealgit -p /srv/git/ -g > "${wwwdir}/index.html"
        
        for dir in "${reposdir}/"*/; do
        
 (DIR) diff --git a/git/files/templates/index.html b/git/files/templates/index.html
       @@ -0,0 +1,33 @@
       +<!DOCTYPE html>
       +<html>
       +<head>
       +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
       +<meta name="viewport" content="width=device-width, initial-scale=1" />
       +<title>repos for days!</title>
       +<link rel="icon" type="image/png" href="favicon.png" />
       +<link rel="stylesheet" type="text/css" href="style.css" />
       +</head>
       +<body>
       +<table>
       +<tr><td><img src="logo.png" alt="" width="32" height="32" /></td>
       +<td><span class="desc">repos for days!</span></td></tr><tr><td></td><td>
       +</td></tr>
       +</table>
       +<hr/>
       +<div id="content">
       +<table id="index">
       +<thead>
       +<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Last commit</b></td></tr>
       +</thead>
       +<tbody>
       +{{range $group, $repos := .}}
       +<tr><td colspan="3"><b>{{if eq $group ""}} {{else}}<hr>{{end}}</b></td></tr>
       +  {{range $repos}}
       +  <tr><td><a href="{{.Name}}">{{.Name}}</a></td><td>{{.Description}}</td><td>{{.LastCommit}}</td></tr>
       +  {{end}}
       +{{end}}
       +</tbody>
       +</table>
       +</div>
       +</body>
       +</html>
       +\ No newline at end of file
 (DIR) diff --git a/git/git.yaml b/git/git.yaml
       @@ -4,9 +4,10 @@ devices:
            source: /srv/services/git
            type: disk
            shift: true
       -  certs:
       -    path: /etc/lighttpd/certs
       -    source: /srv/certs
       +
       +  static:
       +    path: /srv/www
       +    source: /srv/services/static/git
            type: disk
            shift: true
        
       @@ -36,5 +37,4 @@ config:
              - echo "git:*" | chpasswd -e
            packages:
              - git
       -      - lighttpd
              - libgit2-dev
 (DIR) diff --git a/git/init.sh b/git/init.sh
       @@ -6,20 +6,14 @@ incus stop $HOST
        incus delete $HOST
        incus launch images:alpine/3.20/cloud $HOST < $HOST.yaml
        
       -incus file push ./files/lighttpd.conf $HOST/etc/lighttpd/ -pv --mode 644
        incus file push ./files/stagit.sh $HOST/etc/periodic/hourly/ -pv --mode 755
        
        incus exec $HOST -- cloud-init status --wait
       -incus exec $HOST -- rc-service lighttpd start
        incus exec $HOST -- rc-update add sshd
       +incus exec $HOST -- mkdir /root/templates
        
       -incus exec $HOST -- mkdir -p /srv/www
       -incus file push ./files/logo.png $HOST/srv/www/ -pv --mode 644
       -incus file push ./files/style.css $HOST/srv/www/ -pv --mode 644
       -incus file push ./files/favicon.png $HOST/srv/www/ -pv --mode 644
       -
       +incus file push ./files/templates/index.html $HOST/root/templates/ -pv --mode 755
        incus file push ./files/stagit $HOST/usr/bin/ -pv --mode 755
       -incus file push ./files/gostag $HOST/usr/bin/ -pv --mode 755
       -incus file push ./files/stagit-index $HOST/usr/bin/ -pv --mode 755
       +incus file push ./files/sealgit $HOST/usr/bin/ -pv --mode 755
        
        incus exec $HOST -- run-parts /etc/periodic/hourly
 (DIR) diff --git a/sfeed/files/fetch.sh b/sfeed/files/fetch.sh
       @@ -2,4 +2,3 @@
        
        sfeed_update
        sfeed_html /root/.sfeed/feeds/* > /srv/index.html
       -cp /root/.sfeed/style.css /srv/
 (DIR) diff --git a/sfeed/files/lighttpd.conf b/sfeed/files/lighttpd.conf
       @@ -1,29 +0,0 @@
       -var.basedir  = "/var/www/localhost"
       -var.logdir   = "/var/log/lighttpd"
       -var.statedir = "/var/lib/lighttpd"
       -
       -include "mime-types.conf"
       -server.username      = "lighttpd"
       -server.groupname     = "lighttpd"
       -server.document-root = var.basedir + "/htdocs"
       -server.pid-file      = "/run/lighttpd.pid"
       -server.errorlog      = var.logdir  + "/error.log"
       -index-file.names     = ("index.html")
       -
       -server.modules += ( "mod_redirect", "mod_openssl")
       -
       -$SERVER["socket"] == ":443" {
       -    ssl.engine  = "enable"
       -    ssl.pemfile = "/etc/lighttpd/certs/jay.scot.cer"
       -    ssl.privkey = "/etc/lighttpd/certs/jay.scot.key"
       -    ssl.openssl.ssl-conf-cmd = ("MinProtocol" => "TLSv1.3", "Options" => "-ServerPreference")
       -
       -    server.name          = "feeds.jay.scot"
       -    server.document-root = "/srv/"
       -}
       -
       -$HTTP["scheme"] == "http" {
       -    $HTTP["host"] =~ ".*" {
       -        url.redirect = (".*" => "https://%0$0")
       -    }
       -}
 (DIR) diff --git a/sfeed/files/style.css b/sfeed/files/style.css
       @@ -1,15 +0,0 @@
       -body { background-color: #FFFFFF; color: #333333; font-family: monospace; font-size: 11pt; margin: 0; overflow: hidden; padding: 0; }
       -h2 { font-size: 14pt; margin: 0.5em 0; }
       -#sidebar ul, #sidebar ul li { list-style: none; margin: 0; padding: 0; font-size: 11pt; }
       -#sidebar { background-color: inherit; }
       -#sidebar a { padding: 5px 3px 5px 10px; display: block; color: #000000; }
       -a { text-decoration: dashed underline; color: #000000; }
       -u { text-decoration: dashed underline; }
       -a:hover { background-color: #CCCCCC; color: #333333; font-weight: bold; }
       -#sidebar a, #items h2 a { color: inherit; text-decoration: none; }
       -div#items { padding: 0 15px; }
       -body.noframe div#sidebar { height: 100%; left: 0; overflow: auto; position: fixed; top: 0; width: 250px; z-index: 999; }
       -body.noframe div#items { height: 100%; left: 250px; overflow: auto; position: absolute; right: 0; top: 0; }
       -body.noframe div#items.nosidebar { left: 0px; }
       -body.frame { overflow: auto; }
       -body.frame #sidebar br { display: none; }
 (DIR) diff --git a/sfeed/init.sh b/sfeed/init.sh
       @@ -6,8 +6,4 @@ incus stop $HOST
        incus delete $HOST
        incus launch images:alpine/3.20/cloud $HOST < $HOST.yaml
        
       -incus file push ./files/lighttpd.conf $HOST/etc/lighttpd/ -pv --mode 644
        incus file push ./files/fetch.sh $HOST/etc/periodic/hourly/ -pv --mode 755
       -incus exec $HOST -- cloud-init status --wait
       -incus exec $HOST -- rc-service lighttpd start
       -
 (DIR) diff --git a/sfeed/sfeed.yaml b/sfeed/sfeed.yaml
       @@ -4,9 +4,10 @@ devices:
            source: /srv/services/sfeed
            type: disk
            shift: true
       -  certs:
       -    path: /etc/lighttpd/certs
       -    source: /srv/certs
       +
       +  staticfeeds:
       +    path: /srv
       +    source: /srv/services/static/feeds
            type: disk
            shift: true
        
       @@ -21,12 +22,11 @@ config:
          cloud-init.user-data: |
            #cloud-config
            package_upgrade: true
       -    hostname: feeds.jay.scot
       +    hostname: sfeed.jay.scot
            timezone: Europe/London
            manage_resolv_conf: true
            resolv_conf:
              nameservers: ['192.168.2.10', '1.1.1.1']
            packages:
       -      - lighttpd
              - sfeed
              - curl
 (DIR) diff --git a/static/init.sh b/static/init.sh
       @@ -0,0 +1,8 @@
       +#!/bin/sh
       +
       +HOST=static
       +
       +incus stop $HOST
       +incus delete $HOST
       +incus launch images:alpine/3.20/cloud $HOST < $HOST.yaml
       +
 (DIR) diff --git a/static/static.yaml b/static/static.yaml
       @@ -0,0 +1,81 @@
       +devices:
       +  dashboard:
       +    path: /srv/www/dashboard
       +    source: /srv/services/static/dashboard
       +    type: disk
       +
       +  docs:
       +    path: /srv/www/docs
       +    source: /srv/services/static/docs
       +    type: disk
       +
       +  feeds:
       +    path: /srv/www/feeds
       +    source: /srv/services/static/feeds
       +    type: disk
       +
       +  git:
       +    path: /srv/www/git
       +    source: /srv/services/static/git
       +    type: disk
       +
       +  certs:
       +    path: /etc/lighttpd/certs
       +    source: /srv/certs
       +    type: disk
       +    shift: true
       +
       +config:
       +  cloud-init.network-config: |
       +    version: 2
       +    ethernets:
       +      eth0:
       +        addresses:
       +          - 192.168.2.11/24
       +        gateway4: 192.168.2.1
       +  cloud-init.user-data: |
       +    #cloud-config
       +    package_upgrade: true
       +    hostname: static.jay.scot
       +    timezone: Europe/London
       +    manage_resolv_conf: true
       +    resolv_conf:
       +      nameservers: ['192.168.2.10', '1.1.1.1']
       +    packages:
       +      - lighttpd
       +    runcmd:
       +      - rc-service lighttpd start
       +    write_files:
       +      - path: /etc/lighttpd/lighttpd.conf
       +        defer: true
       +        append: true
       +        content: |
       +
       +          server.modules += ( "mod_redirect", "mod_openssl")
       +
       +          ssl.engine  = "enable"
       +          ssl.pemfile = "/etc/lighttpd/certs/jay.scot.cer"
       +          ssl.privkey = "/etc/lighttpd/certs/jay.scot.key"
       +          ssl.openssl.ssl-conf-cmd = ("MinProtocol" => "TLSv1.3", "Options" => "-ServerPreference")
       +
       +          $HTTP["host"] == "dashboard.jay.scot" {
       +              server.document-root = "/srv/www/dashboard"
       +          }
       +
       +          $HTTP["host"] == "docs.jay.scot" {
       +              server.document-root = "/srv/www/docs"
       +          }
       +
       +          $HTTP["host"] == "feeds.jay.scot" {
       +              server.document-root = "/srv/www/feeds"
       +          }
       +
       +          $HTTP["host"] == "git.jay.scot" {
       +              server.document-root = "/srv/www/git"
       +          }
       +
       +          $HTTP["scheme"] == "http" {
       +              $HTTP["host"] =~ ".*" {
       +                  url.redirect = (".*" => "https://%0$0")
       +              }
       +          }