diff --git a/.env.example b/.env.example index be95993..5f41d83 100644 --- a/.env.example +++ b/.env.example @@ -4,9 +4,12 @@ # HTTP server (godeployd) GODEPLOY_ADDR=:8081 -# SQLite database path (godeployd + godeploy-tui) +# SQLite database path (godeployd + godeploy-proxy + godeploy-tui) GODEPLOY_DB=godeploy.db +# Host-based reverse proxy listen address (godeploy-proxy) +GODEPLOY_PROXY_ADDR=:8080 + # Docker network name used for managed containers GODEPLOY_NETWORK=godeploy diff --git a/.github/workflows/security-schedule.yml b/.github/workflows/security-schedule.yml index 592e9cc..8fd6996 100644 --- a/.github/workflows/security-schedule.yml +++ b/.github/workflows/security-schedule.yml @@ -1,6 +1,6 @@ name: security-scheduled -# Weekly vulnerability scan (plan_go.md ETAPA 5 — optional scheduled audit). +# Weekly vulnerability scan for newly disclosed Go dependency issues. on: schedule: - cron: "0 6 * * 1" diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 743cb85..dc1574e 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -31,6 +31,18 @@ builds: goarch: - amd64 - arm64 + - id: godeploy-proxy + main: ./cmd/godeploy-proxy + binary: godeploy-proxy + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 - id: godeploy-logtail main: ./cmd/godeploy-logtail binary: godeploy-logtail @@ -49,6 +61,7 @@ archives: ids: - godeployd - godeploy-tui + - godeploy-proxy - godeploy-logtail formats: - tar.gz diff --git a/CHANGELOG.md b/CHANGELOG.md index eecd1f3..de4e1d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Runnable `godeploy-proxy` command, included in local builds and release archives. +- Explicit product-maturity and known-limitations documentation for production evaluation. - Stage 4 (quality): tests in `internal/pipeline`, `internal/platform/iox`, `internal/platform/sqlpool`; `ExampleParser_Parse_githubPing` in `internal/webhook`; stable `test-cover-check` coverage floor (≥29% with `go test -short`). ### Changed +- Canonical Go module path `github.com/enoquesousa/godeploy-platform`, enabling direct `go install` commands. +- Removed internal planning notes and stray local coverage/error artifacts from the public source tree. - A+ documentation: README (Makefile table aligned with `fmt`/goimports, `validate-full`, `test-cover-check`, `docs/` index), CONTRIBUTING (Conventional Commits), SECURITY (`Cache-Control` header), new `docs/deployment.md` and expanded `docs/architecture.md` / `docs/api.md` / `docs/setup.md`. - `internal/proxy`: reuse one `http.Transport` per proxy instance; `Makefile` `test-cover-check` uses a safer flag order for shells. -- `.golangci.yml`: linter set aligned with the plan (with exclusions documented in `PLAN_PROGRESS.md`). +- `.golangci.yml`: linter set aligned with the documented local and CI validation policy. - Project copy and operator-facing strings internationalised to English (`README`, `docs/`, errors, logs). ### Fixed diff --git a/Makefile b/Makefile index e6ae8f5..42be481 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help fmt vet test test-short test-race test-cover test-cover-check install-hooks tidy build build-daemon build-tui build-logtail clean vulncheck sec lint all validate validate-full generate docker-build run +.PHONY: help fmt vet test test-short test-race test-cover test-cover-check install-hooks tidy build build-daemon build-proxy build-tui build-logtail clean vulncheck sec lint all validate validate-full generate docker-build run GO ?= go @@ -6,8 +6,9 @@ BIN_DIR := bin DAEMON := $(BIN_DIR)/godeployd TUI := $(BIN_DIR)/godeploy-tui LOGTAIL := $(BIN_DIR)/godeploy-logtail +PROXY := $(BIN_DIR)/godeploy-proxy COVERAGE_FILE := coverage.txt -# Minimum total statement coverage for `make test-cover-check` (see PLAN_PROGRESS.md, stage 4). +# Minimum total statement coverage for `make test-cover-check`. COVER_MIN ?= 29 DOCKER_IMAGE ?= godeployd:local @@ -65,13 +66,18 @@ validate: fmt vet lint test build validate-full: fmt vet lint test-short test-cover-check build ## build: Build all binaries -build: build-daemon build-tui build-logtail +build: build-daemon build-proxy build-tui build-logtail ## build-daemon: Build godeployd build-daemon: @mkdir -p $(BIN_DIR) $(GO) build -o $(DAEMON) ./cmd/godeployd +## build-proxy: Build the Host-based reverse proxy +build-proxy: + @mkdir -p $(BIN_DIR) + $(GO) build -o $(PROXY) ./cmd/godeploy-proxy + ## build-tui: Build godeploy-tui build-tui: @mkdir -p $(BIN_DIR) diff --git a/PLAN_PROGRESS.md b/PLAN_PROGRESS.md deleted file mode 100644 index f3c720f..0000000 --- a/PLAN_PROGRESS.md +++ /dev/null @@ -1,63 +0,0 @@ -# Plan progress (`plan_go.md`) - -This file records **where work stopped** so you can continue in stages. The full plan is in `plan_go.md` at the repository root (official stages **0–6**). **Stage 7** is an agreed extension *after* the plan: optional automation and badges described in `plan_go.md` §5.1 / §5.3 and in the former “next step” section of this file. - ---- - -## Current status - -| Stage | Title | Status | -|-------|-------|--------| -| **0** | Technical inventory and baseline | **Done** | -| **1** | Organisation, standards, and repo hygiene | **Done** | -| **2** | Code, architecture, and security | **Done** | -| **3** | A+ documentation | **Done** | -| **4** | Quality, tests, and local automation | **Done** | -| **5** | CI/CD, governance, and polish | **Done** | -| **6** | Final delivery and report | **Done** | -| **7** | Post-plan: scheduled audit, releases, and CodeFactor | **Done** | - ---- - -## Where it stopped (last session) - -- **Stage 7** (2026-05-02): post-`plan_go.md` §5.1 (extra workflows) and §5.3 (CodeFactor badge). - - **`.github/workflows/security-schedule.yml`**: weekly `govulncheck` (Monday 06:00 UTC) and `workflow_dispatch`; `continue-on-error: true` aligned with the CI `vulncheck` job while dependencies lack a published OSV fix on the module. - - **`.goreleaser.yaml`** + **`.github/workflows/release.yml`**: publish to GitHub Releases when pushing a `v*` tag; per-OS/architecture packages with all three binaries (`godeployd`, `godeploy-tui`, `godeploy-logtail`), `formats` / `ids` per GoReleaser v2 (no deprecated properties); `goreleaser check` validated locally. - - **`README.md`**: [CodeFactor](https://www.codefactor.io) badge for `github.com/enoquesousa/godeploy-platform` (register the repo on CodeFactor if the badge does not yet show a grade). - - **`CONTRIBUTING.md`**: **Releases** section with tag flow and `goreleaser check` / snapshot commands. - - **Local validation:** `go build ./...`, `go test -short ./...`, `goreleaser check` succeeded on this clone. - -- **Stage 6** (2026-05-02): final delivery and report (`plan_go.md` *# STAGE 6*). - - **`FINAL.md`** (root): executive report with before/after summary, changelog by stages 0–5, exact commands, architectural decisions, residual risks, simulated A+ evaluation, reviewer positioning, and checklist 6.2 with item status. **Local** file — it is in `.gitignore` (internal document, aligned with the plan). - - **`.github/dependabot.yml`**: Dependabot for `gomod` (`/`), `github-actions` (`/`), and `docker` (`/deployments`), closing the final checklist item from the plan. - - **Local validation:** `go mod tidy`, `go mod verify`, `go build ./...`, `go vet ./...`, `go test -short ./...` succeeded on this clone. - -- **Stage 5** (2026-05-02): CI/CD, governance, and professionalism. - - **`.github/workflows/ci.yml`**: `permissions: contents: read`; `concurrency` to cancel stale runs on PRs; **`lint`** job with `golangci-lint` only; **`vulncheck`** job with dedicated `govulncheck` (`continue-on-error: true` while `github.com/docker/docker` has no module tag fixing reported OSVs — the scan remains visible in checks); **`verify`** job with Go matrix **`1.25.0`** and **`stable`** (`fail-fast: false`); artifact upload **`coverage-.txt`** after tests with `-race`, `-short`, and coverage floor (29%). - - **`CONTRIBUTING.md`**: explicit recommendation to protect `main` with required checks `lint`, `vulncheck`, `verify`. - - **GitHub templates** (already present): `.github/ISSUE_TEMPLATE/*`, `.github/PULL_REQUEST_TEMPLATE.md`, `CODEOWNERS`, `SECURITY.md`. - -- **Stage 4** (2026-05-02): quality, tests, coverage, and lint clean. - - **`.golangci.yml`**: aligned with the plan (errcheck, staticcheck, revive, gocritic, godot, exhaustive, sqlclosecheck, etc.); `gocritic` with `rangeValCopy` disabled (noise vs. copies in Docker structs). - - **`cmd/godeployd`**: `run()` exits via return code instead of `os.Exit` mid-flow (defers and `gocritic` exitAfterDefer); explicit DB close if the Docker client fails (path fixed before refactor). - - **`internal/proxy`**: shared `http.Transport` in `ServeHTTP` (avoids connection leaks / hangs on Windows tests); `CloseIdleConnections` on `Run` shutdown; deterministic hot-reload test with `reloadIfChanged(ctx, true)`. - - **New tests**: `internal/pipeline/pipeline_test.go` (`New` validation, helpers, `waitHTTP200`); `internal/platform/iox/iox_test.go`; `internal/platform/sqlpool/sqlpool_test.go`; `internal/webhook/example_test.go`; observability respects `testing.Short()` so `make test-short` / CI `-short` do not depend on Docker. - - **`Makefile` `test-cover-check`**: flag order `-covermode` before `-coverprofile` (compatible with shells that split `=file`). - - **Coverage**: `go test -short` + floor **≥29%** passing (~30% after new tests). - - **Windows note**: `go test -race` needs **CGO** and a C compiler (e.g. gcc); without it, use CI or install a toolchain; `.githooks/pre-commit` already falls back to `go test -short` without `-race` when `CGO_ENABLED=0`. - -- **Stage 3** (2026-05-02): documentation and godoc (see earlier history). -- **Stages 0–2**: see previous commit history or the table above. - ---- - -## Recommended next step - -Plan **0–7 complete** (0–6 in `plan_go.md` + stage 7 extension). Maintenance: follow `CONTRIBUTING.md` (including **Releases**), review Dependabot PRs, and update `CHANGELOG.md` / docs when product behaviour changes. Optional: register the project on [CodeFactor](https://www.codefactor.io) so the README badge shows a grade. - ---- - -## How to update this file - -After each stage: mark the table row **Done**, update **Where it stopped** with the date and files touched, and set **Recommended next step** to the following stage number. diff --git a/README.md b/README.md index 31b7c1a..df74e2b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

Mini PaaS in Go: detects app type, builds a Docker image, and deploys with domain-based proxy routing and Git webhooks.

- gochangelog-gen Banner + godeploy-platform architecture banner
@@ -19,7 +19,9 @@ --- -**godeploy-platform** is an HTTP daemon (`godeployd`) that receives push webhooks (GitHub or GitLab), clones the repository, detects the runtime (Go, Node, Python, static, or a supplied Dockerfile), generates or reuses a Dockerfile, builds via the Docker Engine API, runs a container with CPU/RAM limits, and updates routes in SQLite for an optional reverse proxy. It also includes a TUI for inspection and a WebSocket log client. The Go module is named `godeploy-platform` (repository root); the badges above assume the canonical repo `github.com/enoquesousa/godeploy-platform`. +**godeploy-platform** is an HTTP daemon (`godeployd`) that receives push webhooks (GitHub or GitLab), clones the repository, detects the runtime (Go, Node, Python, static, or a supplied Dockerfile), generates or reuses a Dockerfile, builds via the Docker Engine API, runs a container with CPU/RAM limits, and updates routes in SQLite for the bundled reverse proxy. It also includes a TUI for inspection and a WebSocket log client. The canonical Go module is `github.com/enoquesousa/godeploy-platform`. + +> **Maturity:** active single-host prototype. The deployment pipeline, health-based route switch and rollback are implemented and tested, but the project is not yet a multi-tenant or highly available control plane. See [Known limitations](#known-limitations) before exposing it to untrusted networks. ## Demo (60-second smoke test) @@ -103,14 +105,13 @@ go build -o bin/godeployd ./cmd/godeployd ### As a binary with `go install` -When the module is published under a `github.com/...` path aligned with `go.mod`, you can use: +Install the daemon, reverse proxy, TUI, or log client directly from the canonical module: ```bash go install github.com/enoquesousa/godeploy-platform/cmd/godeployd@latest +go install github.com/enoquesousa/godeploy-platform/cmd/godeploy-proxy@latest ``` -While `go.mod` declares only `module godeploy-platform`, prefer `make build` from a clone. - ### Docker Compose ```bash @@ -342,45 +343,10 @@ err="new container \"broken-app-...\" did not reach running: ### Step 6 — reverse proxy by domain -`internal/proxy` is a library, not a binary. The quickest local test is a short wrapper sharing the same `GODEPLOY_DB` godeployd updated: +Start the bundled reverse proxy against the same SQLite database updated by `godeployd`: ```bash -mkdir -p cmd/godeploy-proxy-dev -cat > cmd/godeploy-proxy-dev/main.go <<'GO' -package main - -import ( - "context" - "database/sql" - "log" - "os" - "os/signal" - "syscall" - "time" - - _ "modernc.org/sqlite" - "godeploy-platform/internal/proxy" -) - -func main() { - db, err := sql.Open("sqlite", os.Getenv("GODEPLOY_DB")) - if err != nil { - log.Fatal(err) - } - defer db.Close() - p, err := proxy.New(proxy.Config{Addr: ":8090", DB: db, PollInterval: time.Second}) - if err != nil { - log.Fatal(err) - } - ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) - defer stop() - log.Println("proxy on :8090") - if err := p.Run(ctx); err != nil { - log.Fatal(err) - } -} -GO -GODEPLOY_DB=$(pwd)/godeploy.db go run ./cmd/godeploy-proxy-dev +GODEPLOY_DB=$(pwd)/godeploy.db GODEPLOY_PROXY_ADDR=:8090 ./bin/godeploy-proxy ``` In another terminal, hit it with the **Host header** (the proxy routes by domain): @@ -426,7 +392,7 @@ Get-Process -Name godeployd -ErrorAction SilentlyContinue | Stop-Process -Force | `test-cover` | Coverage and `coverage.html` | | `test-cover-check` | `-short` plus coverage floor (`COVER_MIN`, default 29%) | | `tidy` | `go mod tidy` | -| `build` | Build all three binaries into `bin/` | +| `build` | Build all four binaries into `bin/` | | `build-daemon` | `godeployd` only | | `build-tui` | `godeploy-tui` only | | `build-logtail` | `godeploy-logtail` only | @@ -445,6 +411,7 @@ Get-Process -Name godeployd -ErrorAction SilentlyContinue | Stop-Process -Force ## Architecture - `cmd/godeployd` — HTTP server, `internal/pipeline` wiring, webhooks, observability. +- `cmd/godeploy-proxy` — runnable Host-based reverse proxy over the shared SQLite route table. - `cmd/godeploy-tui` — terminal UI over Docker and SQLite. - `cmd/godeploy-logtail` — WebSocket log client. - `internal/pipeline` — orchestration: clone → build → deploy → health → route. @@ -476,12 +443,21 @@ HTTP summary for `godeployd`: Details and examples: [docs/api.md](docs/api.md). Package docs for `internal/` via `go doc` in a local clone (not a stable public API). +## Known limitations + +- Single-host control plane backed by SQLite; no clustering or leader election. +- No tenant model, user authentication, authorization, quotas, or per-application secrets management. +- Docker socket access is highly privileged and must remain restricted to trusted operators. +- TLS termination and public DNS automation are intentionally delegated to external infrastructure. +- Rollback protects the route switch during deployment; disaster recovery and automated SQLite backups remain operator responsibilities. + ## Configuration | Variable | Type | Default | Description | |----------|------|---------|-------------| | `GODEPLOY_ADDR` | string | `:8081` | HTTP listen address | | `GODEPLOY_DB` | path | `godeploy.db` | SQLite file | +| `GODEPLOY_PROXY_ADDR` | string | `:8080` | Host-based reverse proxy listen address | | `GODEPLOY_NETWORK` | string | `godeploy` | Docker bridge network for apps | | `GODEPLOY_IMAGE_PREFIX` | string | `godeploy` | Image name prefix | | `GODEPLOY_HEALTH_PATH` | string | `/` | HTTP health-check path in the pipeline | @@ -534,12 +510,12 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT. [![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=flat&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/enoque-sousa-bb89aa168/) [![GitHub](https://img.shields.io/badge/GitHub-100000?style=flat&logo=github&logoColor=white)](https://github.com/enoquesousa) -[![Portfolio](https://img.shields.io/badge/Portfolio-FF5722?style=flat&logo=target&logoColor=white)](https://enoquesousa.vercel.app) +[![Portfolio](https://img.shields.io/badge/Portfolio-FF5722?style=flat&logo=target&logoColor=white)](https://enoquesousa.com/en) **[⬆ Back to Top](#godeploy-platform)** Made with ❤️ by [Enoque Sousa](https://github.com/enoquesousa) -**Project Status:** Study project +**Project Status:** Active single-host prototype diff --git a/SECURITY.md b/SECURITY.md index 8da7711..66a8a5d 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -13,7 +13,7 @@ Do not post working exploits or production credentials in public issues. - **First acknowledgement**: best effort within **7 days** of a valid report via GitHub Security Advisories. - **Status updates**: when a fix is planned or released, or if the report is declined as out of scope. -- This is a **study / side project**; timelines depend on maintainer availability and are not a commercial SLA. +- This is an **independently maintained prototype**; timelines depend on maintainer availability and are not a commercial SLA. ## Supported versions @@ -25,6 +25,8 @@ The Go client `github.com/docker/docker` is kept on the **latest version compati This repository uses the package **only as an HTTP client** for the Docker Engine API (images, containers, networks). Vectors described in those advisories target **daemon** components (AuthZ, plugins), not the `godeployd` binary. Still, run `govulncheck ./...` on each release and keep Docker Engine updated on the host. +GitHub Dependabot also reports Docker archive/`docker cp` advisories against the module manifest. This project does not call `CopyToContainer`, `CopyFromContainer`, `ContainerArchive`, or the `/containers/{id}/archive` endpoints. No patched module version is currently published; the alerts remain open for tracking and must be reassessed when Docker publishes one. + Mitigations in `godeployd` and related services: - `/webhook`: **body limit** (`http.MaxBytesReader`), **rate limit** per IP (`GODEPLOY_WEBHOOK_RPS` / `GODEPLOY_WEBHOOK_BURST`), **no internal detail leakage** on 500 responses. diff --git a/cmd/godeploy-logtail/main.go b/cmd/godeploy-logtail/main.go index 90cd2a8..4f8753c 100644 --- a/cmd/godeploy-logtail/main.go +++ b/cmd/godeploy-logtail/main.go @@ -9,7 +9,7 @@ import ( "github.com/gorilla/websocket" - "godeploy-platform/internal/platform/iox" + "github.com/enoquesousa/godeploy-platform/internal/platform/iox" ) func main() { diff --git a/cmd/godeploy-proxy/main.go b/cmd/godeploy-proxy/main.go new file mode 100644 index 0000000..35821d9 --- /dev/null +++ b/cmd/godeploy-proxy/main.go @@ -0,0 +1,65 @@ +package main + +import ( + "context" + "database/sql" + "log/slog" + "os" + "os/signal" + "strings" + "syscall" + "time" + + "github.com/enoquesousa/godeploy-platform/internal/platform/iox" + "github.com/enoquesousa/godeploy-platform/internal/platform/sqlpool" + "github.com/enoquesousa/godeploy-platform/internal/proxy" + + _ "modernc.org/sqlite" +) + +func main() { + logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelInfo})) + slog.SetDefault(logger) + os.Exit(run(logger)) +} + +func run(logger *slog.Logger) int { + dbPath := getenv("GODEPLOY_DB", "godeploy.db") + addr := getenv("GODEPLOY_PROXY_ADDR", ":8080") + + db, err := sql.Open("sqlite", dbPath) + if err != nil { + logger.Error("open sqlite", slog.Any("err", err)) + return 1 + } + sqlpool.ForSQLite(db) + defer iox.Close(db) + + p, err := proxy.New(proxy.Config{ + Addr: addr, + DB: db, + PollInterval: time.Second, + Logger: logger, + }) + if err != nil { + logger.Error("configure proxy", slog.Any("err", err)) + return 1 + } + + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + logger.Info("godeploy proxy listening", slog.String("addr", addr), slog.String("db", dbPath)) + if err := p.Run(ctx); err != nil { + logger.Error("proxy stopped", slog.Any("err", err)) + return 1 + } + return 0 +} + +func getenv(key, fallback string) string { + if value := strings.TrimSpace(os.Getenv(key)); value != "" { + return value + } + return fallback +} diff --git a/cmd/godeploy-proxy/main_test.go b/cmd/godeploy-proxy/main_test.go new file mode 100644 index 0000000..cf33467 --- /dev/null +++ b/cmd/godeploy-proxy/main_test.go @@ -0,0 +1,15 @@ +package main + +import "testing" + +func TestGetenv(t *testing.T) { + t.Setenv("GODEPLOY_TEST_VALUE", " configured ") + if got := getenv("GODEPLOY_TEST_VALUE", "fallback"); got != "configured" { + t.Fatalf("getenv() = %q, want configured", got) + } + + t.Setenv("GODEPLOY_TEST_VALUE", " ") + if got := getenv("GODEPLOY_TEST_VALUE", "fallback"); got != "fallback" { + t.Fatalf("getenv() with whitespace = %q, want fallback", got) + } +} diff --git a/cmd/godeploy-tui/main.go b/cmd/godeploy-tui/main.go index 642b3f3..4bb7aa0 100644 --- a/cmd/godeploy-tui/main.go +++ b/cmd/godeploy-tui/main.go @@ -16,8 +16,8 @@ import ( "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" - "godeploy-platform/internal/platform/iox" - "godeploy-platform/internal/platform/sqlpool" + "github.com/enoquesousa/godeploy-platform/internal/platform/iox" + "github.com/enoquesousa/godeploy-platform/internal/platform/sqlpool" _ "modernc.org/sqlite" ) diff --git a/cmd/godeployd/main.go b/cmd/godeployd/main.go index f406719..21368bc 100644 --- a/cmd/godeployd/main.go +++ b/cmd/godeployd/main.go @@ -16,11 +16,11 @@ import ( "github.com/docker/docker/client" - "godeploy-platform/internal/middleware" - "godeploy-platform/internal/pipeline" - "godeploy-platform/internal/platform/iox" - "godeploy-platform/internal/platform/sqlpool" - "godeploy-platform/internal/webhook" + "github.com/enoquesousa/godeploy-platform/internal/middleware" + "github.com/enoquesousa/godeploy-platform/internal/pipeline" + "github.com/enoquesousa/godeploy-platform/internal/platform/iox" + "github.com/enoquesousa/godeploy-platform/internal/platform/sqlpool" + "github.com/enoquesousa/godeploy-platform/internal/webhook" _ "modernc.org/sqlite" ) diff --git a/cmd/godeployd/main_test.go b/cmd/godeployd/main_test.go index 8d09ed9..66a45b0 100644 --- a/cmd/godeployd/main_test.go +++ b/cmd/godeployd/main_test.go @@ -9,9 +9,9 @@ import ( "strings" "testing" - "godeploy-platform/internal/middleware" - "godeploy-platform/internal/pipeline" - "godeploy-platform/internal/webhook" + "github.com/enoquesousa/godeploy-platform/internal/middleware" + "github.com/enoquesousa/godeploy-platform/internal/pipeline" + "github.com/enoquesousa/godeploy-platform/internal/webhook" ) func TestGetenv(t *testing.T) { diff --git a/cmd/godeployd/routes.go b/cmd/godeployd/routes.go index e59fa03..65e8c2e 100644 --- a/cmd/godeployd/routes.go +++ b/cmd/godeployd/routes.go @@ -6,8 +6,8 @@ import ( "github.com/docker/docker/client" - "godeploy-platform/internal/middleware" - "godeploy-platform/internal/observability" + "github.com/enoquesousa/godeploy-platform/internal/middleware" + "github.com/enoquesousa/godeploy-platform/internal/observability" ) // routeDeps configures HTTP routes that depend on optional services. diff --git a/cover b/cover deleted file mode 100644 index 79b28a0..0000000 --- a/cover +++ /dev/null @@ -1 +0,0 @@ -mode: atomic diff --git a/coverage b/coverage deleted file mode 100644 index 79b28a0..0000000 --- a/coverage +++ /dev/null @@ -1 +0,0 @@ -mode: atomic diff --git a/docs/deployment.md b/docs/deployment.md index 397b2f5..0ad6aa2 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -6,10 +6,10 @@ - `deployments/docker-compose.yml` shows a mounted Docker socket and volume for `GODEPLOY_DB`. Tune ports, networks, and **never** expose `GODEPLOY_WEBHOOK_SECRET` in logs or public images. - Set `GODEPLOY_WEBHOOK_SECRET` in production and keep webhook rate limits (`GODEPLOY_WEBHOOK_RPS` / `GODEPLOY_WEBHOOK_BURST`) appropriate for expected traffic. -## App reverse proxy (`internal/proxy`) +## App reverse proxy (`godeploy-proxy`) -- Separate binary (integrate in your startup): typically listens on `:80` or `:8080` and reads routes from the **same** SQLite the daemon updates after deploy. -- After each `UpsertRoute`, call `NotifyReload` on `*proxy.Proxy` if you want the route propagated without waiting for the poll (this repository’s pipeline follows that pattern when wired to the proxy). +- Run the bundled `godeploy-proxy` binary on the deployment host. It listens on `GODEPLOY_PROXY_ADDR` (default `:8080`) and reads routes from the **same** SQLite database the daemon updates after deploy. +- Route changes are detected through the shared version counter and become active on the next polling interval (one second by default). ## Quick checklist diff --git a/err.txt b/err.txt deleted file mode 100644 index e69de29..0000000 diff --git a/go.mod b/go.mod index a8ca1ad..20d2a9d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module godeploy-platform +module github.com/enoquesousa/godeploy-platform go 1.25.9 diff --git a/internal/builder/builder.go b/internal/builder/builder.go index 5f00d3d..33450b6 100644 --- a/internal/builder/builder.go +++ b/internal/builder/builder.go @@ -20,8 +20,8 @@ import ( "github.com/docker/docker/client" "github.com/docker/docker/pkg/jsonmessage" - "godeploy-platform/internal/detector" - "godeploy-platform/internal/platform/iox" + "github.com/enoquesousa/godeploy-platform/internal/detector" + "github.com/enoquesousa/godeploy-platform/internal/platform/iox" ) // Builder wraps a Docker API client and performs image builds for godeploy. diff --git a/internal/builder/builder_test.go b/internal/builder/builder_test.go index ff60fc5..f4d0d8e 100644 --- a/internal/builder/builder_test.go +++ b/internal/builder/builder_test.go @@ -13,8 +13,8 @@ import ( "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" - "godeploy-platform/internal/detector" - "godeploy-platform/internal/integrationtest" + "github.com/enoquesousa/godeploy-platform/internal/detector" + "github.com/enoquesousa/godeploy-platform/internal/integrationtest" ) func TestResolveDockerfile(t *testing.T) { diff --git a/internal/builder/templates.go b/internal/builder/templates.go index 0098b7b..88316a1 100644 --- a/internal/builder/templates.go +++ b/internal/builder/templates.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "godeploy-platform/internal/detector" + "github.com/enoquesousa/godeploy-platform/internal/detector" ) func dockerfileTemplate(rt detector.Runtime) (string, error) { diff --git a/internal/detector/example_test.go b/internal/detector/example_test.go index b09b453..7a2900b 100644 --- a/internal/detector/example_test.go +++ b/internal/detector/example_test.go @@ -8,7 +8,7 @@ import ( "path/filepath" "testing" - "godeploy-platform/internal/detector" + "github.com/enoquesousa/godeploy-platform/internal/detector" ) func ExampleDetect() { diff --git a/internal/observability/observability_test.go b/internal/observability/observability_test.go index c488d91..07d5664 100644 --- a/internal/observability/observability_test.go +++ b/internal/observability/observability_test.go @@ -8,7 +8,7 @@ import ( "github.com/docker/docker/client" - "godeploy-platform/internal/integrationtest" + "github.com/enoquesousa/godeploy-platform/internal/integrationtest" ) func TestStatsHandler(t *testing.T) { diff --git a/internal/observability/stats.go b/internal/observability/stats.go index 7f5f745..418be8b 100644 --- a/internal/observability/stats.go +++ b/internal/observability/stats.go @@ -12,7 +12,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" - "godeploy-platform/internal/platform/iox" + "github.com/enoquesousa/godeploy-platform/internal/platform/iox" ) // ContainerStat is one row of Docker usage telemetry returned by [Collector.Collect]. diff --git a/internal/observability/ws_logs.go b/internal/observability/ws_logs.go index 9a856ee..921fbd8 100644 --- a/internal/observability/ws_logs.go +++ b/internal/observability/ws_logs.go @@ -15,8 +15,8 @@ import ( "github.com/docker/docker/pkg/stdcopy" "github.com/gorilla/websocket" - "godeploy-platform/internal/middleware" - "godeploy-platform/internal/platform/iox" + "github.com/enoquesousa/godeploy-platform/internal/middleware" + "github.com/enoquesousa/godeploy-platform/internal/platform/iox" ) // Stream values used in [LogMessage.Stream]. diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go index 0dc5dc9..5c4b0e8 100644 --- a/internal/pipeline/pipeline.go +++ b/internal/pipeline/pipeline.go @@ -21,10 +21,10 @@ import ( "github.com/docker/docker/client" "github.com/docker/go-connections/nat" - "godeploy-platform/internal/builder" - "godeploy-platform/internal/detector" - "godeploy-platform/internal/proxy" - "godeploy-platform/internal/scheduler" + "github.com/enoquesousa/godeploy-platform/internal/builder" + "github.com/enoquesousa/godeploy-platform/internal/detector" + "github.com/enoquesousa/godeploy-platform/internal/proxy" + "github.com/enoquesousa/godeploy-platform/internal/scheduler" ) // Config wires database, Docker, network defaults, health probing, and logging for [New]. diff --git a/internal/pipeline/pipeline_test.go b/internal/pipeline/pipeline_test.go index e244782..b5dbae7 100644 --- a/internal/pipeline/pipeline_test.go +++ b/internal/pipeline/pipeline_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "godeploy-platform/internal/detector" + "github.com/enoquesousa/godeploy-platform/internal/detector" _ "modernc.org/sqlite" ) diff --git a/internal/proxy/store.go b/internal/proxy/store.go index 8a6d6bf..81ff034 100644 --- a/internal/proxy/store.go +++ b/internal/proxy/store.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "godeploy-platform/internal/platform/iox" + "github.com/enoquesousa/godeploy-platform/internal/platform/iox" ) // Store persists domain -> target (ip:port) routes in SQLite. diff --git a/internal/scheduler/scheduler.go b/internal/scheduler/scheduler.go index b4b0edf..60bcaab 100644 --- a/internal/scheduler/scheduler.go +++ b/internal/scheduler/scheduler.go @@ -19,7 +19,7 @@ import ( "github.com/docker/docker/pkg/stdcopy" "github.com/docker/go-connections/nat" - "godeploy-platform/internal/platform/iox" + "github.com/enoquesousa/godeploy-platform/internal/platform/iox" ) const ( diff --git a/internal/scheduler/scheduler_test.go b/internal/scheduler/scheduler_test.go index f628040..6df6334 100644 --- a/internal/scheduler/scheduler_test.go +++ b/internal/scheduler/scheduler_test.go @@ -8,7 +8,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" - "godeploy-platform/internal/integrationtest" + "github.com/enoquesousa/godeploy-platform/internal/integrationtest" ) func TestAppValidate(t *testing.T) { diff --git a/internal/webhook/example_test.go b/internal/webhook/example_test.go index 68dd89d..734d2aa 100644 --- a/internal/webhook/example_test.go +++ b/internal/webhook/example_test.go @@ -7,7 +7,7 @@ import ( "net/http" "net/http/httptest" - "godeploy-platform/internal/webhook" + "github.com/enoquesousa/godeploy-platform/internal/webhook" ) func ExampleParser_Parse_githubPing() {