From f2b08174bc5023f13a943479df28ef126aea4c24 Mon Sep 17 00:00:00 2001 From: XShine555 Date: Mon, 21 Sep 2026 22:09:43 +0200 Subject: [PATCH] Drop the local Postgres/Zitadel/SeaweedFS stack, use shared Infrastructure This repo ran its own separate copy of Postgres, Zitadel and SeaweedFS, none of which are actually wired into the Go backend yet (auth and file storage are still unchecked TODOs in the README). Removed that unused duplicate stack (deploy/docker-compose.dev.yml, deploy/postgres-init/) in favor of the shared Infrastructure repo also used by Musify and Ping. make dev-infra now brings up Infrastructure instead, and backend/.env.example points at its ports (Postgres on dockermanager_db, Zitadel, SeaweedFS) as placeholders for when those features are implemented. --- Makefile | 8 ++- README.md | 23 ++++--- backend/.env.example | 13 +++- deploy/docker-compose.dev.yml | 64 ------------------- .../postgres-init/001-create-zitadel-db.sql | 1 - 5 files changed, 29 insertions(+), 80 deletions(-) delete mode 100644 deploy/docker-compose.dev.yml delete mode 100644 deploy/postgres-init/001-create-zitadel-db.sql diff --git a/Makefile b/Makefile index de53137..2295327 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,14 @@ .PHONY: dev-infra dev-infra-down backend frontend migrate-up migrate-down lint test +# Postgres, Zitadel and SeaweedFS are not run by this repo. They're shared +# infrastructure in a separate Infrastructure repo; ../../Infrastructure +# below assumes it's checked out as a sibling of Admin. Adjust the path if +# yours isn't. See that repo's own README. dev-infra: - docker compose -f deploy/docker-compose.dev.yml up -d + docker compose -f ../../Infrastructure/compose.yml -f ../../Infrastructure/compose.dev.yml up -d dev-infra-down: - docker compose -f deploy/docker-compose.dev.yml down + docker compose -f ../../Infrastructure/compose.yml -f ../../Infrastructure/compose.dev.yml down backend: cd backend && go run ./cmd/server diff --git a/README.md b/README.md index 6db2543..869c7c1 100644 --- a/README.md +++ b/README.md @@ -31,16 +31,17 @@ never reach the browser. **File storage** (planned): SeaweedFS, S3 compatible. -Everything ships as Docker Compose for local development: Postgres, Zitadel -and SeaweedFS run as infrastructure while the Go API and the SvelteKit app -run directly on the host for fast iteration. +Postgres, Zitadel and SeaweedFS are not run by this repo: they're shared +infrastructure that lives in the separate `Infrastructure` git repository, +used by other projects too. This repo has no infrastructure containers of +its own. The Go API and the SvelteKit app run directly on the host for fast +iteration. ## Project layout ``` backend/ Go API: HTTP router, config, the Docker connector, SQL migrations frontend/ SvelteKit app -deploy/ docker-compose.dev.yml and Postgres init scripts ``` ## Running it locally @@ -52,20 +53,22 @@ make backend make frontend ``` -That brings up Postgres, Zitadel and SeaweedFS, then starts the API on -`http://localhost:8090` and the frontend on `http://localhost:5173`. The API -port is 8090 instead of the usual 8080 because that one is often already -taken by something else on the same machine. +`make dev-infra` brings up the shared `Infrastructure` stack (Postgres, +Zitadel, SeaweedFS). Then `make backend` starts the API on +`http://localhost:8090` and `make frontend` starts the frontend on +`http://localhost:5173`. The API port is 8090 instead of the usual 8080 +because that one is often already taken by something else on the same +machine. Useful endpoints while developing: `/healthz` and `/api/containers`. ## Status -- [x] Monorepo layout (`backend/`, `frontend/`, `deploy/`) +- [x] Monorepo layout (`backend/`, `frontend/`) - [x] Go backend: `chi` router, env based config, health check - [x] `HostConnector` / `LocalConnector`: container listing via the Docker SDK - [x] Frontend consuming `/api/containers` -- [x] Dev infrastructure with Postgres, Zitadel and SeaweedFS +- [x] Dev infrastructure (Postgres, Zitadel, SeaweedFS) via the shared `Infrastructure` repo - [x] Initial schema (`hosts`, `services`, `audit_log`) - [ ] OIDC login against Zitadel (BFF pattern) - [ ] Persisting hosts and services through the backend diff --git a/backend/.env.example b/backend/.env.example index a79e4b8..6a51ae1 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -2,14 +2,21 @@ APP_ENV=development PORT=8090 CORS_ALLOWED_ORIGINS=http://localhost:5173 -DATABASE_URL=postgres://dockermanager:dockermanager@localhost:5432/dockermanager?sslmode=disable +# Postgres, Zitadel and SeaweedFS come from the shared ../../Infrastructure +# stack (`make dev-infra`), not from a container in this repo. Credentials +# must match Infrastructure's own .env. +DATABASE_URL=postgres://postgres:postgres@host.docker.internal:5432/dockermanager_db?sslmode=disable -ZITADEL_ISSUER=http://localhost:8081 +# Not wired into the backend yet (see README). These point at Infrastructure's +# Zitadel for when OIDC login is implemented. +ZITADEL_ISSUER=http://host.docker.internal:8080 ZITADEL_CLIENT_ID= ZITADEL_CLIENT_SECRET= SESSION_SECRET=change-me-in-production -S3_ENDPOINT=http://localhost:8333 +# Not wired into the backend yet. Points at Infrastructure's SeaweedFS for +# when file storage is implemented. +S3_ENDPOINT=http://host.docker.internal:8333 S3_BUCKET=dockermanager S3_ACCESS_KEY= S3_SECRET_KEY= diff --git a/deploy/docker-compose.dev.yml b/deploy/docker-compose.dev.yml deleted file mode 100644 index 4792b3a..0000000 --- a/deploy/docker-compose.dev.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: dockermanager-dev - -services: - postgres: - image: postgres:17-alpine - restart: unless-stopped - environment: - POSTGRES_USER: dockermanager - POSTGRES_PASSWORD: dockermanager - POSTGRES_DB: dockermanager - ports: - - "5432:5432" - volumes: - - dm_postgres_data:/var/lib/postgresql/data - - ./postgres-init:/docker-entrypoint-initdb.d:ro - healthcheck: - test: ["CMD-SHELL", "pg_isready -U dockermanager"] - interval: 5s - timeout: 5s - retries: 10 - - zitadel: - image: ghcr.io/zitadel/zitadel:latest - restart: unless-stopped - command: start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled - environment: - ZITADEL_DATABASE_POSTGRES_HOST: postgres - ZITADEL_DATABASE_POSTGRES_PORT: 5432 - ZITADEL_DATABASE_POSTGRES_DATABASE: zitadel - ZITADEL_DATABASE_POSTGRES_USER_USERNAME: dockermanager - ZITADEL_DATABASE_POSTGRES_USER_PASSWORD: dockermanager - ZITADEL_DATABASE_POSTGRES_USER_SSL_MODE: disable - ZITADEL_DATABASE_POSTGRES_ADMIN_USERNAME: dockermanager - ZITADEL_DATABASE_POSTGRES_ADMIN_PASSWORD: dockermanager - ZITADEL_DATABASE_POSTGRES_ADMIN_SSL_MODE: disable - ZITADEL_EXTERNALSECURE: "false" - ZITADEL_EXTERNALPORT: "8081" - ZITADEL_EXTERNALDOMAIN: localhost - ZITADEL_FIRSTINSTANCE_ORG_HUMAN_USERNAME: admin@dockermanager.local - ZITADEL_FIRSTINSTANCE_ORG_HUMAN_PASSWORD: Passw0rd!Change - ports: - - "8081:8080" - depends_on: - postgres: - condition: service_healthy - healthcheck: - test: ["CMD", "/app/zitadel", "ready"] - interval: 10s - timeout: 5s - retries: 10 - - seaweedfs: - image: chrislusf/seaweedfs:latest - restart: unless-stopped - command: server -s3 -s3.port=8333 -dir=/data - ports: - - "8333:8333" - - "9333:9333" - volumes: - - dm_seaweed_data:/data - -volumes: - dm_postgres_data: - dm_seaweed_data: diff --git a/deploy/postgres-init/001-create-zitadel-db.sql b/deploy/postgres-init/001-create-zitadel-db.sql deleted file mode 100644 index b2f9e1c..0000000 --- a/deploy/postgres-init/001-create-zitadel-db.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE DATABASE zitadel;