From 182d77354e65a3276d167e9e95dfce60377593b3 Mon Sep 17 00:00:00 2001 From: Thomas Peetz Date: Thu, 29 Jan 2026 23:36:15 +0100 Subject: [PATCH] Add kontor-echo and kontor-fiber to kontor-pod resolve #35 (cherry picked from commit 05e26e512da9c237adbb58510df2b490837cd836) --- kontor-echo/{Dockerfile => Containerfile} | 8 +--- kontor-echo/cmd/kontor/main.go | 2 +- kontor-fiber/{Dockerfile => Containerfile} | 8 +--- kontor-fiber/cmd/kontor/main.go | 2 +- script/setup | 55 +++++++++++++++++++++- 5 files changed, 60 insertions(+), 15 deletions(-) rename kontor-echo/{Dockerfile => Containerfile} (73%) rename kontor-fiber/{Dockerfile => Containerfile} (73%) diff --git a/kontor-echo/Dockerfile b/kontor-echo/Containerfile similarity index 73% rename from kontor-echo/Dockerfile rename to kontor-echo/Containerfile index 08b639f..bbb66d7 100644 --- a/kontor-echo/Dockerfile +++ b/kontor-echo/Containerfile @@ -1,5 +1,5 @@ # ---------- Stage 1: Build ---------- -FROM golang:1.25-alpine AS builder +FROM docker.io/library/golang:1.25-alpine AS builder # Set the working directory WORKDIR /app # Ensure a portable, static-ish binary @@ -18,11 +18,7 @@ FROM alpine:latest WORKDIR /app # Install runtime dependencies you actually need RUN apk add --no-cache ca-certificates tzdata curl -# Create non-root user for security -RUN addgroup -S kontor && adduser -S -G kontor -H -s /sbin/nologin kontor # Copy the binary and set ownership -COPY --from=builder --chown=kontor:kontor /app/kontor /app/kontor -# Run as non-root user -USER kontor +COPY --from=builder /app/kontor /app/kontor # Set the entrypoint command ENTRYPOINT ["/app/kontor"] diff --git a/kontor-echo/cmd/kontor/main.go b/kontor-echo/cmd/kontor/main.go index 1d9ef14..aef6b85 100644 --- a/kontor-echo/cmd/kontor/main.go +++ b/kontor-echo/cmd/kontor/main.go @@ -49,6 +49,6 @@ func main() { handler.SetupComicRoutes(group) handler.SetupMediaRoutes(group) - e.Logger.Fatal(e.Start(":8700")) + e.Logger.Fatal(e.Start(":8400")) log.Println("Kontor finished") } diff --git a/kontor-fiber/Dockerfile b/kontor-fiber/Containerfile similarity index 73% rename from kontor-fiber/Dockerfile rename to kontor-fiber/Containerfile index 08b639f..bbb66d7 100644 --- a/kontor-fiber/Dockerfile +++ b/kontor-fiber/Containerfile @@ -1,5 +1,5 @@ # ---------- Stage 1: Build ---------- -FROM golang:1.25-alpine AS builder +FROM docker.io/library/golang:1.25-alpine AS builder # Set the working directory WORKDIR /app # Ensure a portable, static-ish binary @@ -18,11 +18,7 @@ FROM alpine:latest WORKDIR /app # Install runtime dependencies you actually need RUN apk add --no-cache ca-certificates tzdata curl -# Create non-root user for security -RUN addgroup -S kontor && adduser -S -G kontor -H -s /sbin/nologin kontor # Copy the binary and set ownership -COPY --from=builder --chown=kontor:kontor /app/kontor /app/kontor -# Run as non-root user -USER kontor +COPY --from=builder /app/kontor /app/kontor # Set the entrypoint command ENTRYPOINT ["/app/kontor"] diff --git a/kontor-fiber/cmd/kontor/main.go b/kontor-fiber/cmd/kontor/main.go index 28ba3ea..efe67d2 100644 --- a/kontor-fiber/cmd/kontor/main.go +++ b/kontor-fiber/cmd/kontor/main.go @@ -35,7 +35,7 @@ func main() { handler.SetupComicRoutes(api) handler.SetupMediaRoutes(api) // Listen on port 8900 - app.Listen(":8600") + app.Listen(":8500") log.Println("Kontor finished") } diff --git a/script/setup b/script/setup index fef8094..61882c4 100755 --- a/script/setup +++ b/script/setup @@ -23,6 +23,8 @@ else -p 8100:8100 \ -p 8200:8200 \ -p 8300:8300 \ + -p 8400:8400 \ + -p 8500:8500 \ -p 8900:8080 \ -p 61616:61616 \ -p 8161:8161 \ @@ -145,9 +147,60 @@ else --name kontor-quarkus \ --label "io.containers.autoupdate=local" \ --label "PODMAN_SYSTEMD_UNIT=container-kontor-quarkus.service" \ - --health-cmd='curl -f http://kontor-api:8300/q/health || exit 1' \ + --health-cmd='curl -f http://kontor-quarkus:8300/q/health || exit 1' \ --health-interval=1s \ --health-timeout=5s \ --health-retries=10 \ localhost/kontor-quarkus:0.3.0 fi + +echo "==> Setting up container kontor-echo" +if podman image exists localhost/kontor-echo:0.3.0; then + echo " => Image localhost/kontor-echo:0.3.0 available" +else + echo " => Baue Image localhost/kontor-echo:0.3.0" + buildah build -t kontor-echo:0.3.0 kontor-echo +fi +if podman container exists kontor-echo; then + if podman ps -q --filter "name=kontor-echo"; then + echo " => kontor-echo is running" + fi +else + podman run -d \ + --replace \ + --pod kontor \ + --name kontor-echo \ + --label "io.containers.autoupdate=local" \ + --label "PODMAN_SYSTEMD_UNIT=container-kontor-echo.service" \ + --health-cmd='curl -f http://kontor-echo:8400/health || exit 1' \ + --health-interval=1s \ + --health-timeout=5s \ + --health-retries=10 \ + localhost/kontor-echo:0.3.0 +fi + +echo "==> Setting up container kontor-fiber" +if podman image exists localhost/kontor-fiber:0.3.0; then + echo " => Image localhost/kontor-fiber:0.3.0 available" +else + echo " => Baue Image localhost/kontor-fiber:0.3.0" + buildah build -t kontor-fiber:0.3.0 kontor-fiber +fi +if podman container exists kontor-fiber; then + if podman ps -q --filter "name=kontor-fiber"; then + echo " => kontor-fiber is running" + fi +else + podman run -d \ + --replace \ + --pod kontor \ + --name kontor-fiber \ + --label "io.containers.autoupdate=local" \ + --label "PODMAN_SYSTEMD_UNIT=container-kontor-fiber.service" \ + --health-cmd='curl -f http://kontor-echo:8500/health || exit 1' \ + --health-interval=1s \ + --health-timeout=5s \ + --health-retries=10 \ + localhost/kontor-fiber:0.3.0 +fi +