Website service target setup (#2)

This PR contains the work done to add and setup the *Website* service target, a **Hummingbird** server app, into the Xcode project as a SwiftPM package with full support for containerization and driven by a `Makefile` file.

To provide further details about the work done:

* Swift package — SwiftPM manifest with a Website executable, related library, and test targets; depends on **hummingbird** and **swift-configuration**.
* Containerization — Multi-stage `Dockerfile` producing a static-linked release build with jemalloc, running as a non-root user on port 8080. Production and local-dev `docker-compose` files included.
* Configuration — `.env.local` template (with `.env` git-ignored) and `.dockerignore`/`.gitignore` entries.
* Makefile — Self-documenting operational commands:
  * pkg — SwiftPM: _build, release, test, clean, reset, deps, outdated, update_
  * img — Docker lifecycle: _build, mount, unmount, release_

Notes

* New service only — no changes to existing code; nothing else in the repo is affected.
* App logic is currently scaffolding; this PR establishes the service structure, build, and deployment tooling.

Reviewed-on: rock-n-code/loud-amsterdam#2
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit is contained in:
2026-06-27 02:26:33 +00:00
committed by javier
parent a15271772e
commit 08b210e7c6
14 changed files with 489 additions and 0 deletions
@@ -0,0 +1,62 @@
import Configuration
import Hummingbird
import Logging
/// Build application
/// - Parameter reader: configuration reader
func application(
reader: ConfigReader
) async throws -> some ApplicationProtocol {
let logLevel = reader.string(
forKey: "log.level",
as: Logger.Level.self,
default: .info
)
let serverName = reader.string(
forKey: "http.serverName",
default: "LoudWebsite"
)
return Application(
router: try router(),
configuration: ApplicationConfiguration(
reader: reader.scoped(to: "http")
),
logger: logger(
serverName: serverName,
logLevel: logLevel
)
)
}
// MARK: - Helpers
// Request context used by application
private typealias AppRequestContext = BasicRequestContext
/// Build logger
private func logger(
serverName: String,
logLevel: Logger.Level
) -> Logger {
var logger = Logger(label: serverName)
logger.logLevel = logLevel
return logger
}
/// Build router
private func router() throws -> Router<AppRequestContext> {
let router = Router(context: AppRequestContext.self)
router.addMiddleware {
LogRequestsMiddleware(.info)
}
router.get("/") { _, _ in
return "Hello!"
}
return router
}
+28
View File
@@ -0,0 +1,28 @@
import Configuration
import Hummingbird
import Logging
@main
struct App {
static func main() async throws {
let reader = try await ConfigReader(
providers: [
CommandLineArgumentsProvider(),
EnvironmentVariablesProvider(),
EnvironmentVariablesProvider(
environmentFilePath: ".env",
allowMissing: true
),
InMemoryProvider(values: [
"http.serverName": "LoudWebsite"
]),
]
)
let app = try await application(
reader: reader
)
try await app.runService()
}
}