prime8dev

prime8dev
git clone https://git.prime8.dev/prime8dev.git
Log | Files | Refs | README | LICENSE

commit 0a2bf3a39871a86b22e95a9cb4423a82e5f857c5
parent 6e7dd0b9027e5d88ad1124d6fbbdc1adb1906718
Author: Damian Myrda <damian@prime8.dev>
Date:   Tue,  7 Apr 2026 23:05:27 -0500

fix: configure web and ssh ports via environment variables

Diffstat:
MDockerfile | 4+++-
Mcmd/server/main.go | 2+-
Menv.example | 5+++--
Minternal/ssh/server.go | 14+++++++++++++-
4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/Dockerfile b/Dockerfile @@ -17,8 +17,10 @@ COPY --from=build /server ./server COPY --from=build /app/static ./static COPY --from=build /app/content ./content -ENV PORT=3000 +ENV SSH_PORT=22 EXPOSE 22 + +ENV WEB_PORT=3000 EXPOSE 3000 CMD ["./server"] diff --git a/cmd/server/main.go b/cmd/server/main.go @@ -59,7 +59,7 @@ func run() error { r.Get("/api/blog/{id}", h.BlogDetailHandler) r.Get("/api/wakatime", h.WakaTimeHandler) - port := os.Getenv("PORT") + port := os.Getenv("WEB_PORT") if port == "" { port = "3000" } diff --git a/env.example b/env.example @@ -1,4 +1,5 @@ APP_ENV=dev -PORT=3000 -GITLAB_HOST= +SSH_PORT=22 +WEB_PORT=3000 +GITLAB_HOST=git.prime8.dev WAKATIME_API_KEY=your_wakatime_api_key_here diff --git a/internal/ssh/server.go b/internal/ssh/server.go @@ -6,6 +6,8 @@ import ( "fmt" "log/slog" "net" + "os" + "strings" "time" "git.prime8.dev/moncheeta/prime8dev/internal/tui" @@ -16,7 +18,7 @@ import ( ) const ( - publicAddr = ":22" + defaultSSHPort = "22" hostKeyPath = ".ssh/public_ssh_ed25519" idleTimeout = 90 * time.Second maxTimeout = 10 * time.Minute @@ -27,6 +29,7 @@ const ( ) func Run(ctx context.Context, logger *slog.Logger) error { + publicAddr := sshListenAddr() limiter := newIPLimiter(rateLimitWindow, rateLimitMax, rateLimitBlock, rateLimitMaxIPs) server, err := wish.NewServer( @@ -90,3 +93,12 @@ func Run(ctx context.Context, logger *slog.Logger) error { logger.Info("public ssh server stopped") return nil } + +func sshListenAddr() string { + port := strings.TrimSpace(os.Getenv("SSH_PORT")) + if port == "" { + port = defaultSSHPort + } + + return ":" + port +}