initial commit
This commit is contained in:
+168
@@ -0,0 +1,168 @@
|
||||
version: '3'
|
||||
|
||||
vars:
|
||||
DATABASE_URL: postgres://postgres:postgres@localhost:5453/postgres?sslmode=disable
|
||||
NATS_URL: nats://localhost:4222
|
||||
NATS_SUBJECT: postgres.public.inventory
|
||||
APP_NAME: inventory-cdc-demo
|
||||
APP_SHARE: '{{.HOME}}/.local/share/live-inventory-cdc-demo'
|
||||
APP_BIN: '{{.HOME}}/.local/bin/inventory-cdc-demo'
|
||||
QUADLET_DIR: '{{.HOME}}/.config/containers/systemd'
|
||||
USER_UNIT_DIR: '{{.HOME}}/.config/systemd/user'
|
||||
|
||||
tasks:
|
||||
default:
|
||||
desc: list available tasks
|
||||
cmds:
|
||||
- go tool task --list
|
||||
|
||||
run:
|
||||
desc: show the common development and production commands
|
||||
cmds:
|
||||
- echo "Development - go tool task infra, then go tool task backend"
|
||||
- echo "Production - go tool task prod-install, then go tool task prod-start"
|
||||
- echo "Open - http://localhost:8080"
|
||||
|
||||
infra:
|
||||
desc: development - start Postgres, NATS, and Debezium with compose
|
||||
cmds:
|
||||
- podman compose -f compose.yml up
|
||||
|
||||
backend:
|
||||
desc: development - run native Go backend against compose infrastructure
|
||||
env:
|
||||
DATABASE_URL: "{{.DATABASE_URL}}"
|
||||
NATS_URL: "{{.NATS_URL}}"
|
||||
NATS_SUBJECT: "{{.NATS_SUBJECT}}"
|
||||
cmds:
|
||||
- go run ./cmd/server
|
||||
|
||||
up:
|
||||
desc: development - alias for task infra
|
||||
cmds:
|
||||
- go tool task infra
|
||||
|
||||
down:
|
||||
desc: development - stop compose infrastructure
|
||||
cmds:
|
||||
- podman compose -f compose.yml down
|
||||
|
||||
seed:
|
||||
desc: development - generate a fresh burst of inventory CDC events
|
||||
cmds:
|
||||
- podman compose -f compose.yml --profile tools run --rm seed
|
||||
|
||||
inspect:
|
||||
desc: development - inspect Debezium messages in NATS JetStream
|
||||
cmds:
|
||||
- podman compose -f compose.yml --profile tools run --rm nats-cli /scripts/inspect.sh
|
||||
|
||||
build:
|
||||
desc: build the native Go backend binary
|
||||
env:
|
||||
CGO_ENABLED: "0"
|
||||
cmds:
|
||||
- go build -o bin/{{.APP_NAME}} ./cmd/server
|
||||
|
||||
binary:
|
||||
desc: run the built backend binary
|
||||
env:
|
||||
DATABASE_URL: "{{.DATABASE_URL}}"
|
||||
NATS_URL: "{{.NATS_URL}}"
|
||||
NATS_SUBJECT: "{{.NATS_SUBJECT}}"
|
||||
cmds:
|
||||
- ./bin/{{.APP_NAME}}
|
||||
|
||||
fmt:
|
||||
desc: format Go files
|
||||
cmds:
|
||||
- go fmt ./...
|
||||
|
||||
vet:
|
||||
desc: vet Go files
|
||||
cmds:
|
||||
- go vet ./...
|
||||
|
||||
test:
|
||||
desc: run tests
|
||||
cmds:
|
||||
- go test ./...
|
||||
|
||||
check:
|
||||
desc: run formatting, vet, and tests
|
||||
cmds:
|
||||
- go tool task fmt
|
||||
- go tool task vet
|
||||
- go tool task test
|
||||
|
||||
prod-install:
|
||||
desc: production - install user-level quadlets and Go backend service
|
||||
env:
|
||||
CGO_ENABLED: "0"
|
||||
cmds:
|
||||
- go build -o bin/{{.APP_NAME}} ./cmd/server
|
||||
- mkdir -p "{{.QUADLET_DIR}}" "{{.USER_UNIT_DIR}}" "{{.HOME}}/.local/bin" "{{.APP_SHARE}}"
|
||||
- cp bin/{{.APP_NAME}} "{{.APP_BIN}}"
|
||||
- cp -R postgres scripts "{{.APP_SHARE}}/"
|
||||
- cp application.prod.properties "{{.APP_SHARE}}/application.properties"
|
||||
- cp linux-files/dot_config/containers/systemd/cdc* "{{.QUADLET_DIR}}/"
|
||||
- cp linux-files/dot_config/systemd/user/cdc-inventory.service "{{.USER_UNIT_DIR}}/"
|
||||
- systemctl --user daemon-reload
|
||||
- echo "Installed production units. Run go tool task prod-start, then open http://localhost:8080"
|
||||
|
||||
prod-infra:
|
||||
desc: production - start quadlet-managed Postgres, NATS, and Debezium
|
||||
cmds:
|
||||
- systemctl --user start cdc-postgres.service cdc-nats.service cdc-debezium.service
|
||||
|
||||
prod-backend:
|
||||
desc: production - start the Go backend user service
|
||||
cmds:
|
||||
- systemctl --user start cdc-inventory.service
|
||||
|
||||
prod-start:
|
||||
desc: production - start quadlet infrastructure and Go backend
|
||||
cmds:
|
||||
- systemctl --user start cdc-postgres.service cdc-nats.service cdc-debezium.service cdc-inventory.service
|
||||
|
||||
prod-restart:
|
||||
desc: production - restart the full demo
|
||||
cmds:
|
||||
- systemctl --user restart cdc-postgres.service cdc-nats.service cdc-debezium.service cdc-inventory.service
|
||||
|
||||
prod-status:
|
||||
desc: production - show user service status
|
||||
cmds:
|
||||
- systemctl --user status cdc-postgres.service cdc-nats.service cdc-debezium.service cdc-inventory.service --no-pager
|
||||
|
||||
prod-logs:
|
||||
desc: production - follow logs for demo user services
|
||||
cmds:
|
||||
- journalctl --user -fu cdc-postgres.service -fu cdc-nats.service -fu cdc-debezium.service -fu cdc-inventory.service
|
||||
|
||||
prod-down:
|
||||
desc: production - stop all user services
|
||||
cmds:
|
||||
- systemctl --user stop cdc-inventory.service cdc-debezium.service cdc-nats.service cdc-postgres.service
|
||||
|
||||
prod-enable:
|
||||
desc: production - enable services at user login
|
||||
cmds:
|
||||
- systemctl --user enable cdc-postgres.service cdc-nats.service cdc-debezium.service cdc-inventory.service
|
||||
|
||||
prod-disable:
|
||||
desc: production - disable services at user login
|
||||
cmds:
|
||||
- systemctl --user disable cdc-inventory.service cdc-debezium.service cdc-nats.service cdc-postgres.service
|
||||
|
||||
prod-seed:
|
||||
desc: production - generate a fresh burst of inventory CDC events
|
||||
cmds:
|
||||
- systemctl --user start cdc-seed.service
|
||||
- journalctl --user -u cdc-seed.service -n 80 --no-pager
|
||||
|
||||
prod-inspect:
|
||||
desc: production - inspect Debezium messages in NATS JetStream
|
||||
cmds:
|
||||
- systemctl --user start cdc-inspect.service
|
||||
- journalctl --user -u cdc-inspect.service -n 120 --no-pager
|
||||
Reference in New Issue
Block a user