chore: refactored sipp-go to single binary
39e898ea
3 file(s) · +11 −30
| 1 | 1 | # Build from repo root: docker build -t sipp-go -f apps/sipp-go/Dockerfile . |
|
| 2 | - | FROM golang:1.24-bookworm AS builder |
|
| 2 | + | FROM golang:1.25-bookworm AS builder |
|
| 3 | 3 | WORKDIR /app |
|
| 4 | 4 | COPY crates-go/ ./crates-go/ |
|
| 5 | 5 | COPY apps/sipp-go/go.mod apps/sipp-go/go.sum ./apps/sipp-go/ |
|
| 6 | 6 | WORKDIR /app/apps/sipp-go |
|
| 7 | 7 | RUN go mod download |
|
| 8 | 8 | COPY apps/sipp-go/ ./ |
|
| 9 | - | RUN CGO_ENABLED=0 go build -o /sipp-server ./cmd/server |
|
| 9 | + | RUN CGO_ENABLED=0 go build -o /sipp . |
|
| 10 | 10 | ||
| 11 | 11 | FROM debian:bookworm-slim |
|
| 12 | 12 | RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* |
|
| 13 | - | COPY --from=builder /sipp-server /usr/local/bin/sipp-server |
|
| 13 | + | COPY --from=builder /sipp /usr/local/bin/sipp |
|
| 14 | 14 | WORKDIR /data |
|
| 15 | 15 | ENV HOST=0.0.0.0 |
|
| 16 | 16 | ENV PORT=3000 |
|
| 17 | 17 | EXPOSE 3000 |
|
| 18 | - | CMD ["sipp-server"] |
|
| 18 | + | CMD ["sipp", "server"] |
| 1 | 1 | # sipp-go |
|
| 2 | 2 | ||
| 3 | - | Go rewrite of [sipp](../sipp). Two binaries: |
|
| 3 | + | Go rewrite of [sipp](../sipp). Single binary with subcommands: |
|
| 4 | 4 | ||
| 5 | - | - root (`.`) — CLI dispatcher: `sipp server`, or `sipp <file>` to upload a |
|
| 6 | - | snippet to a remote instance via the JSON API. |
|
| 7 | - | - `cmd/server` — web server only (HTTP + admin + API + syntax highlight via |
|
| 8 | - | `github.com/alecthomas/chroma/v2`). |
|
| 5 | + | - `sipp server [--host H] [--port P]` — web server (HTTP + admin + API + |
|
| 6 | + | syntax highlight via `github.com/alecthomas/chroma/v2`). |
|
| 7 | + | - `sipp tui` — interactive TUI. |
|
| 8 | + | - `sipp auth` — save remote URL + API key to config. |
|
| 9 | + | - `sipp <file>` — upload a snippet to a remote instance via the JSON API. |
|
| 9 | 10 | ||
| 10 | 11 | ## Notes vs Rust version |
|
| 11 | 12 | ||
| 12 | - | - **Interactive TUI not ported.** The Rust binary uses `ratatui` + |
|
| 13 | - | `crossterm`; build with the Rust version if you need it. |
|
| 13 | + | - TUI uses Bubble Tea (Rust uses `ratatui` + `crossterm`). |
|
| 14 | 14 | - Syntax highlighting uses Chroma (replaces syntect). The darkmatter |
|
| 15 | 15 | `.tmTheme` is not reused; Chroma's `monokai` style ships by default. |
|
| 16 | 16 | - Snippet schema and routes match the Rust app; existing SQLite files are |
|
| 20 | 20 | ||
| 21 | 21 | ```bash |
|
| 22 | 22 | cp .env.example .env |
|
| 23 | - | go run ./cmd/server |
|
| 24 | - | # or |
|
| 25 | 23 | go run . server --port 3000 |
|
| 26 | 24 | ``` |
|
| 27 | 25 | ||
| 1 | - | package main |
|
| 2 | - | ||
| 3 | - | import ( |
|
| 4 | - | "log" |
|
| 5 | - | ||
| 6 | - | "github.com/stevedylandev/andromeda/apps/sipp-go/server" |
|
| 7 | - | "github.com/stevedylandev/andromeda/crates-go/config" |
|
| 8 | - | ) |
|
| 9 | - | ||
| 10 | - | func main() { |
|
| 11 | - | config.LoadDotEnv(".env") |
|
| 12 | - | host := config.Getenv("HOST", "127.0.0.1") |
|
| 13 | - | port := config.GetenvInt("PORT", 3000) |
|
| 14 | - | if err := server.Run(host, port); err != nil { |
|
| 15 | - | log.Fatal(err) |
|
| 16 | - | } |
|
| 17 | - | } |