-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
186 lines (160 loc) · 8.54 KB
/
Copy pathMakefile
File metadata and controls
186 lines (160 loc) · 8.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
COMPOSE := docker compose -f infra/docker-compose.yml
APP_PROJECT := ./src/AutoNate.Web
APP_PROFILE := http
APP_PORT := 5108
DAPR_APP_ID := autonate-web
DAPR_HTTP_PORT := 3500
DAPR_GRPC_PORT := 50001
DAPR_PLACEMENT_HOST_ADDRESS := 127.0.0.1:50006
DAPR_SCHEDULER_HOST_ADDRESS := 127.0.0.1:50007
MOUNT_ROOT := ./infra/mounts
POSTGRES_MOUNT := $(MOUNT_ROOT)/postgres/data
REDIS_MOUNT := $(MOUNT_ROOT)/redis/data
NATS_MOUNT := $(MOUNT_ROOT)/nats/data
SCHEDULER_MOUNT := $(MOUNT_ROOT)/dapr-scheduler/data
DAPR_DASHBOARD_COMPONENTS := $(MOUNT_ROOT)/dapr-dashboard/components
FLOWABLE_DAPR_COMPONENTS := $(MOUNT_ROOT)/flowable-dapr/components
.PHONY: app-container app-container-down lockfiles preflight infra-prepare infra-ensure infra-up infra-up-dashboard infra-down infra-reset infra-logs infra-ps app app-dapr rider-sidecar rider-sidecar-status rider-sidecar-stop rider-sidecar-restart e2e e2e-install
# Verify the documented prerequisites and port availability before anything
# tries to start. Reports every problem in one pass so a machine is fixed once,
# rather than once per missing tool. Required versions live in
# infra/prerequisites; ports are derived from the compose file.
# Regenerate every packages.lock.json after changing a PackageReference.
# CI restores in locked mode, so a changed reference without a regenerated lock
# file fails the build rather than silently resolving something new.
# The plugin projects are listed separately because plugins/Directory.Build.props
# does not chain to the root one and they are not in the solution (see #120).
lockfiles:
dotnet restore AutoNate.sln --force-evaluate
dotnet restore plugins/HelloPlugin --force-evaluate
dotnet restore plugins/Auditor --force-evaluate
preflight:
./infra/preflight.sh
infra-prepare:
mkdir -p $(POSTGRES_MOUNT) $(REDIS_MOUNT) $(NATS_MOUNT) $(SCHEDULER_MOUNT) $(DAPR_DASHBOARD_COMPONENTS) $(FLOWABLE_DAPR_COMPONENTS) $(MOUNT_ROOT)/flowable $(MOUNT_ROOT)/dapr-placement
cp ./infra/dapr/components/*.yaml $(DAPR_DASHBOARD_COMPONENTS)/
# Rewrite the flowable-dapr pubsub copy to use host.docker.internal.
# Idempotent because we always start from the source file and stream
# into the destination — sed -i.bak is fragile (silently no-ops on a
# second run) and leaves a backup file behind.
sed 's|nats://localhost:4222|nats://host.docker.internal:4222|' ./infra/dapr/components/pubsub.yaml > $(FLOWABLE_DAPR_COMPONENTS)/pubsub.yaml
./infra/ensure-nats-stream.sh
infra-ensure: preflight
./infra/ensure-up.sh
rider-sidecar: infra-ensure
./infra/start-autonate-web-sidecar.sh
rider-sidecar-status:
./infra/check-autonate-web-sidecar.sh
rider-sidecar-stop:
./infra/stop-autonate-web-sidecar.sh
rider-sidecar-restart: infra-ensure
./infra/restart-autonate-web-sidecar.sh
infra-up: preflight infra-prepare
$(COMPOSE) up -d
infra-up-dashboard: infra-prepare
./infra/preflight.sh --profile dashboard
$(COMPOSE) --profile dashboard up -d
# ── The `keycloak` profile: a real OIDC + SAML identity provider ────────────
#
# Off by default. Two things have to be true before it is useful, and both fail
# late and confusingly if left to chance, so they are checked here:
#
# 1. Admin credentials exist. There is no working default (invariant 1 holds
# for development dependencies too), and compose cannot enforce it without
# breaking `make infra-up` for everyone who never touches Keycloak — a
# `:?` guard is evaluated at parse time, not at profile start.
#
# 2. `keycloak` resolves to 127.0.0.1 on this machine. The issuer URL is
# http://keycloak:PORT so that it is identical from the browser, from a
# host-run Auton8, and from a containerised one; without the hosts entry
# the browser cannot reach it, and the symptom is an issuer mismatch deep
# inside an OIDC library rather than a name that does not resolve.
KEYCLOAK_PORT ?= $(shell sed -n 's/^AUTONATE_KEYCLOAK_PORT=//p' .env 2>/dev/null | tail -1)
KEYCLOAK_PORT := $(if $(KEYCLOAK_PORT),$(KEYCLOAK_PORT),8082)
keycloak-check:
@sh infra/keycloak/check.sh
keycloak-up: infra-prepare keycloak-check
./infra/preflight.sh --profile keycloak
$(COMPOSE) --profile keycloak up -d keycloak
@echo ""
@echo "Keycloak is starting. Admin console: http://keycloak:$(KEYCLOAK_PORT)/admin/"
@echo "Realm 'auton8' — OIDC discovery:"
@echo " http://keycloak:$(KEYCLOAK_PORT)/realms/auton8/.well-known/openid-configuration"
@echo "See docs/DEVELOPMENT.md for what to put in Auton8's provider configuration."
keycloak-down:
$(COMPOSE) --profile keycloak rm -sf keycloak
keycloak-logs:
$(COMPOSE) --profile keycloak logs -f keycloak
infra-down:
$(COMPOSE) down
infra-reset:
$(COMPOSE) down
# Guard against the variables being empty (which would expand to
# `rm -rf` with no operand and either no-op or error depending on the
# shell), and quote each path so a whitespace-bearing MOUNT_ROOT
# doesn't get word-split into a much wider deletion target.
@test -n "$(MOUNT_ROOT)" || { echo "MOUNT_ROOT is empty; refusing to rm -rf"; exit 1; }
@test -n "$(POSTGRES_MOUNT)" || { echo "POSTGRES_MOUNT is empty; refusing to rm -rf"; exit 1; }
rm -rf "$(POSTGRES_MOUNT)" "$(REDIS_MOUNT)" "$(NATS_MOUNT)" "$(SCHEDULER_MOUNT)" "$(DAPR_DASHBOARD_COMPONENTS)" "$(FLOWABLE_DAPR_COMPONENTS)"
$(MAKE) infra-prepare
infra-logs:
$(COMPOSE) logs -f
infra-ps:
$(COMPOSE) ps
# Run the whole product as containers: Docker is the only prerequisite.
#
# Both compose files are needed. The app services live in the main file behind
# the `app` profile; docker-compose.app.yml rewires flowable's and hocuspocus's
# callbacks to reach the app over the compose network instead of at
# host.docker.internal, which is only correct when the app is a host process.
app-container: preflight infra-prepare
# The tracked component files address localhost, which is right for the
# host-run sidecar: the services publish their ports on the host. This
# sidecar shares the app CONTAINER's network namespace, where localhost is
# the app itself — so every service address has to become its compose
# service name. Missing one is not a warning: daprd exits with
# INIT_COMPONENT_FAILURE and takes the app down with it, because the app
# refuses to run without a sidecar.
#
# Streamed from the source files rather than edited in place, so this is
# idempotent — `sed -i` silently no-ops on a second run and leaves a .bak
# behind, the same trap infra-prepare documents.
mkdir -p $(MOUNT_ROOT)/autonate-web-dapr/components
sed -e 's|nats://localhost:4222|nats://nats:4222|' -e 's|localhost:6379|redis:6379|' \
./infra/dapr/components/pubsub.yaml > $(MOUNT_ROOT)/autonate-web-dapr/components/pubsub.yaml
sed -e 's|nats://localhost:4222|nats://nats:4222|' -e 's|localhost:6379|redis:6379|' \
./infra/dapr/components/statestore.yaml > $(MOUNT_ROOT)/autonate-web-dapr/components/statestore.yaml
$(COMPOSE) -f infra/docker-compose.app.yml --profile app up -d --build
# Stop ONLY the app containers. `compose --profile app down` would tear down
# the entire project — every supporting service with it — which is not what
# "stop the app" means to anyone typing this, and cost a full stack restart
# the first time it was used.
app-container-down:
$(COMPOSE) -f infra/docker-compose.app.yml rm -sf autonate-web autonate-web-dapr
app: app-dapr
app-dapr: infra-ensure
dapr run \
--app-id $(DAPR_APP_ID) \
--app-port $(APP_PORT) \
--dapr-http-port $(DAPR_HTTP_PORT) \
--dapr-grpc-port $(DAPR_GRPC_PORT) \
--placement-host-address $(DAPR_PLACEMENT_HOST_ADDRESS) \
--scheduler-host-address $(DAPR_SCHEDULER_HOST_ADDRESS) \
--resources-path $(DAPR_DASHBOARD_COMPONENTS) \
-- dotnet run --project $(APP_PROJECT) --launch-profile $(APP_PROFILE)
# Playwright E2E suite. The fixture (AutoNateE2EFixture) creates a dedicated
# `AutoNate_E2E` Postgres database each run and replays
# infra/postgres/init/02-create-autonate-app-schema.sql against it, so this
# target needs only the same infra `app` does. We build the test project up
# front so the Playwright install script (which is shipped inside the test
# assembly) can be invoked via `dotnet exec`, then `dotnet test --no-build`
# skips a redundant rebuild.
e2e-install:
dotnet build tests/AutoNate.E2E.Tests
# Idempotent: a no-op when the right Chromium build is already on disk.
dotnet exec \
--runtimeconfig tests/AutoNate.E2E.Tests/bin/Debug/net10.0/AutoNate.E2E.Tests.runtimeconfig.json \
--depsfile tests/AutoNate.E2E.Tests/bin/Debug/net10.0/AutoNate.E2E.Tests.deps.json \
tests/AutoNate.E2E.Tests/bin/Debug/net10.0/Microsoft.Playwright.dll install chromium
e2e: infra-ensure e2e-install
dotnet test tests/AutoNate.E2E.Tests --no-build