Converted the website service project into a reusable template.

This commit is contained in:
2026-07-11 16:20:33 +02:00
parent a4906f8f26
commit 4a8413359f
12 changed files with 296 additions and 38 deletions
+5 -5
View File
@@ -12,7 +12,7 @@
HOST_CONTAINER=containers.rock-n-code.com
# Owner of the container running the Website service.
HOST_OWNER=loud
HOST_OWNER=site
# Password for authenticating to the container registry.
HOST_PASSWORD=
@@ -36,7 +36,7 @@ IMAGE_TAG=latest
# --- Application config -------------------------------------------------------
# Server name reported by the HTTP service.
HTTP_SERVER_NAME=LoudWebsite
HTTP_SERVER_NAME=SiteWebsite
# Log verbosity: trace | debug | info | notice | warning | error | critical
LOG_LEVEL=info
@@ -55,13 +55,13 @@ DATABASE_HOST=localhost
DATABASE_PORT=3306
# Name of the database to connect to.
DATABASE_NAME=loud-ams
DATABASE_NAME=site
# Username of the database to connect as.
DATABASE_USERNAME=loud-ams
DATABASE_USERNAME=site
# Provide the real password via the environment or a secret — never commit it.
DATABASE_PASSWORD=loud-ams
DATABASE_PASSWORD=site
# TLS posture when connecting: off | prefer | require (use `require` in production).
DATABASE_TLS=off
+3 -3
View File
@@ -90,9 +90,9 @@ db-shell: ## Open a SQL shell on the local database instance
--profile database \
exec mariadb \
mariadb \
--user=$(or $(DATABASE_USERNAME),loud) \
--password=$(or $(DATABASE_PASSWORD),loud) \
$(or $(DATABASE_NAME),loud)
--user=$(or $(DATABASE_USERNAME),site) \
--password=$(or $(DATABASE_PASSWORD),site) \
$(or $(DATABASE_NAME),site)
.PHONY: db-unmount
db-unmount: ## Stop and remove the local database instance (keeps the data volume)
+6 -6
View File
@@ -1,5 +1,5 @@
# Loud Website
The **Loud** public website service — a [Hummingbird](https://github.com/hummingbird-project/hummingbird) server that renders a static landing page and serves the site's static assets.
# Site Website
The **Site** public website service — a [Hummingbird](https://github.com/hummingbird-project/hummingbird) server that renders a static landing page and serves the site's static assets.
## Overview
The service:
@@ -73,7 +73,7 @@ A dotted config key maps to an environment variable by upper-casing, splitting c
| --- | --- | --- | --- |
| `http.host` | `HTTP_HOST` | _none_ | Host the server binds to. Supplied via the `--http-host` CLI flag (the Docker image passes `0.0.0.0`). |
| `http.port` | `HTTP_PORT` | _none_ | Port the server listens on. Supplied via the `--http-port` CLI flag (the Docker image passes `8080`). |
| `http.serverName` | `HTTP_SERVER_NAME` | `LoudWebsite` | Server name and logger label. |
| `http.serverName` | `HTTP_SERVER_NAME` | `SiteWebsite` | Server name and logger label. |
### Logging
| Config key | Environment variable | Default | Description |
@@ -87,8 +87,8 @@ A dotted config key maps to an environment variable by upper-casing, splitting c
| `database.migrate` | `DATABASE_MIGRATE` (flag `--database-migrate`) | `false` | When set, run the migrations and exit instead of serving. |
| `database.host` | `DATABASE_HOST` | `localhost` | MySQL/MariaDB host. Ignored for `inMemory`. |
| `database.port` | `DATABASE_PORT` | `3306` | MySQL/MariaDB port. Ignored for `inMemory`. |
| `database.name` | `DATABASE_NAME` | `loud` | Database name. Ignored for `inMemory`. |
| `database.username` | `DATABASE_USERNAME` | `loud` | Database username. Ignored for `inMemory`. |
| `database.name` | `DATABASE_NAME` | `site` | Database name. Ignored for `inMemory`. |
| `database.username` | `DATABASE_USERNAME` | `site` | Database username. Ignored for `inMemory`. |
| `database.password` | `DATABASE_PASSWORD` | _(empty)_ | Database password. Provide via the environment/a secret — never commit it. |
| `database.tls` | `DATABASE_TLS` | `prefer` | TLS posture when connecting: `off`, `prefer`, or `require`. Ignored for `inMemory`. |
| `database.pool.maxPerEventLoop` | `DATABASE_POOL_MAX_PER_EVENT_LOOP` | `4` | Maximum pooled connections per event loop. Ignored for `inMemory`. |
@@ -203,7 +203,7 @@ The Makefile and Compose files read these from a `.env` file (or the environment
| `IMAGE_PLATFORM` | Build platform (e.g. `linux/amd64`). |
| `HOST_PORT` | Host port mapped to the container's `8080` (default `8080`). |
| `LOG_LEVEL` | Runtime log level (default `info`). |
| `HTTP_SERVER_NAME` | Runtime server name (default `LoudWebsite`). |
| `HTTP_SERVER_NAME` | Runtime server name (default `SiteWebsite`). |
| `SECURITY_STRICT_TRANSPORT_SECURITY` | HSTS header value (default `max-age=31536000; includeSubDomains`). |
| `DATABASE_DRIVER` | `inMemory` (default) or `mysql`. Set to `mysql` in production to use a managed database. |
| `DATABASE_HOST`, `DATABASE_PORT`, `DATABASE_NAME`, `DATABASE_USERNAME`, `DATABASE_PASSWORD` | MySQL/MariaDB connection (when `DATABASE_DRIVER=mysql`). Provide the password via a secret. |
@@ -8,9 +8,9 @@ extension String {
/// The default MySQL/MariaDB host.
public static let host = "localhost"
/// The default database name.
public static let name = "loud"
public static let name = "site"
/// The default database username.
public static let username = "loud"
public static let username = "site"
/// The default TLS posture token.
public static let tls = "prefer"
/// The TLS token disabling TLS.
@@ -47,6 +47,6 @@ extension String {
/// A namespace for the server string constants.
public enum Server {
/// The website server's name.
public static let name = "LoudWebsite"
public static let name = "SiteWebsite"
}
}
+4 -4
View File
@@ -26,7 +26,7 @@ services:
# docker compose --profile database up mariadb
mariadb:
image: mariadb:11
container_name: ${HOST_OWNER:-loud}-db
container_name: ${HOST_OWNER:-site}-db
restart: unless-stopped
profiles:
- database
@@ -34,9 +34,9 @@ services:
- "127.0.0.1:${DATABASE_PORT:-3306}:3306"
environment:
MARIADB_RANDOM_ROOT_PASSWORD: "yes"
MARIADB_DATABASE: ${DATABASE_NAME:-loud-ams}
MARIADB_USER: ${DATABASE_USERNAME:-loud-ams}
MARIADB_PASSWORD: ${DATABASE_PASSWORD:-loud-ams}
MARIADB_DATABASE: ${DATABASE_NAME:-site}
MARIADB_USER: ${DATABASE_USERNAME:-site}
MARIADB_PASSWORD: ${DATABASE_PASSWORD:-site}
MARIADB_AUTO_UPGRADE: "1"
command:
- "--character-set-server=utf8mb4"
+4 -4
View File
@@ -1,4 +1,4 @@
name: loud-platform
name: site-platform
# Production base configuration.
# Deploys a pre-built image pulled from a registry — no build step.
@@ -19,7 +19,7 @@ services:
- "${HOST_PORT:-8080}:8080"
environment:
LOG_LEVEL: ${LOG_LEVEL:-info}
HTTP_SERVER_NAME: ${HTTP_SERVER_NAME:-LoudWebsite}
HTTP_SERVER_NAME: ${HTTP_SERVER_NAME:-SiteWebsite}
SECURITY_STRICT_TRANSPORT_SECURITY: "${SECURITY_STRICT_TRANSPORT_SECURITY:-max-age=31536000; includeSubDomains}"
# Persistence: in-memory by default; set DATABASE_DRIVER=mysql to run against a
# managed MySQL/MariaDB database. Provide the password via the environment or a
@@ -27,7 +27,7 @@ services:
DATABASE_DRIVER: ${DATABASE_DRIVER:-mysql}
DATABASE_HOST: ${DATABASE_HOST:-localhost}
DATABASE_PORT: ${DATABASE_PORT:-3306}
DATABASE_NAME: ${DATABASE_NAME:-loud-ams}
DATABASE_USERNAME: ${DATABASE_USERNAME:-loud-ams}
DATABASE_NAME: ${DATABASE_NAME:-site}
DATABASE_USERNAME: ${DATABASE_USERNAME:-site}
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-}
DATABASE_TLS: ${DATABASE_TLS:-require}