commit 18f54afcac197b926e80550299d1b4b589383000 Author: VpEngOps Date: Mon Sep 7 08:07:25 2026 -0500 farmd MVP scaffold: HTTP server, healthz, dashboard placeholder Go printer-farm manager (Wave 1, Redmine #855). Cloudron-deployable, OIDC via platform provider planned; Moonraker/OctoPrint/Bambu adapters + Dolibarr connector are the next milestones. Dockerfile: multi-stage, non-root, no Node anywhere in the chain. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c7ec59 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +farmd +*.db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d332099 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# STLP Shop Manager (farmd) - Go printer-farm manager. +# Multi-stage: build in golang, run minimal alpine. No Node anywhere. +FROM golang:1.23-alpine AS build +WORKDIR /src +COPY go.mod ./ +COPY cmd/ ./cmd/ +COPY internal/ ./internal/ +RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /out/farmd ./cmd/farmd + +FROM alpine:3.20 +RUN apk add --no-cache ca-certificates && adduser -D -u 1000 app +COPY --from=build /out/farmd /usr/local/bin/farmd +COPY web/templates/ /app/web/templates/ +USER 1000:1000 +ENV FARMD_ADDR=:3000 FARMD_DB_PATH=/app/data/farmd.db +VOLUME /app/data +EXPOSE 3000 +HEALTHCHECK CMD wget -qO- http://127.0.0.1:3000/healthz || exit 1 +ENTRYPOINT ["/usr/local/bin/farmd"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..9769274 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# STLP Shop Manager + +Go printer-farm manager for Starting Line Productions — Etsy batch printing +with Dolibarr ERP/MRP integration. Cloudron-deployable, OIDC via the platform +provider. + +Design + proposal: Redmine [#855](https://projects.knownelement.com/issues/855) +(program: [#836](https://projects.knownelement.com/issues/836), RDStack). + +## Status + +MVP scaffold: HTTP server + /healthz + dashboard placeholder. Next: printer +adapters (Moonraker/Klipper, OctoPrint, Bambu), job queue + state machine, +Dolibarr connector, OIDC login (Cloudron platform provider). + +## Build & run + + go build ./cmd/farmd + FARMD_ADDR=:3000 FARMD_DB_PATH=/tmp/farmd.db ./farmd + +Docker: `docker build -t farmd .` (serves :3000, data at /app/data). + +## Layout + + cmd/farmd/ entrypoint + internal/server/ HTTP surface (healthz, dashboard) + web/templates/ embedded dashboard templates diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b179289 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.knownelement.com/StartingLineProductions.com/STLPShopManager + +go 1.23 diff --git a/internal/server/server.go b/internal/server/server.go new file mode 100644 index 0000000..7db7d76 --- /dev/null +++ b/internal/server/server.go @@ -0,0 +1,46 @@ +// Package server wires the HTTP surface: health, dashboard, and (coming) +// the printer/job APIs. See Redmine #855 for the component design. +package server + +import ( + "fmt" + "html/template" + "net/http" +) + +type Config struct { + Addr string + DBPath string +} + +type Server struct { + cfg Config + mux *http.ServeMux +} + +func New(cfg Config) *Server { + s := &Server{cfg: cfg, mux: http.NewServeMux()} + s.mux.HandleFunc("/healthz", s.health) + s.mux.HandleFunc("/", s.index) + return s +} + +func (s *Server) Run() error { + return http.ListenAndServe(s.cfg.Addr, s.mux) +} + +func (s *Server) health(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, "ok") +} + +// index is the farm dashboard placeholder. The real board (printer cards, +// job queue, batch view) lands with the printer adapters. +func (s *Server) index(w http.ResponseWriter, _ *http.Request) { + t, err := template.ParseFiles("web/templates/index.html") + if err != nil { + http.Error(w, "template: "+err.Error(), http.StatusInternalServerError) + return + } + _ = t.Execute(w, map[string]string{"Toolset": "farmd 0.1.0-dev"}) +} diff --git a/web/templates/index.html b/web/templates/index.html new file mode 100644 index 0000000..3e423b8 --- /dev/null +++ b/web/templates/index.html @@ -0,0 +1,11 @@ + + +STLP Shop Manager + + + +

STLP Shop Manager

+

Printer farm manager — build {{.Toolset}}. Dashboard under construction (Redmine #855).

+

Planned: printer cards (Moonraker/OctoPrint/Bambu), job queue, Etsy batch view, Dolibarr sync.

+ +