Skip to content

Commit dd2cbe1

Browse files
weastlerCopilot
andauthored
feat(infrastructure): add Azure deployment foundations (#196)
<!-- Use a conventional commit-style title, such as "fix(hub): retain prototype history". --> ## Why <!-- Explain the problem and why this change matters in a short, plain-English paragraph. Link the issue when applicable. --> The Azure installation wizard needs reusable provisioning and release foundations that operators can also use without the wizard. This PR separates those foundations from the guided installation flow so they can be reviewed independently. ## What changes <!-- Describe what becomes different for a first-time reader. Explain necessary terms. Include accurate Mermaid diagrams when they clarify the proposal, using before/after diagrams when helpful. Add screenshots for meaningful UI changes. --> <!-- Omit validation sections, checklists, and routine test/CI summaries such as "CI is green" or "tests passed". Mention only known verification gaps that affect the change, not disclaimers about drafting this description. --> <!-- For UI changes, prune obsolete and duplicate stories in the affected catalogues as part of the change. Explain removed UI or consolidated coverage where needed; see hub/docs/storybook.md#ui-changes-and-pull-request-evidence. --> Adds optional Terraform modules for an installation-owned container registry and Key Vault, and a temporary private-network job that provisions fresh database roles. Each module has its own state and lifecycle. The main installation exposes authoritative resource IDs, supports an explicit deployment storage grant, and retains Azure-assigned properties without ignoring other configuration drift. Native release commands validate revision metadata, drain active and inactive replicas before setup, avoid reactivating an already-active revision, and accept empty output from successful Azure mutations. Command failures identify the operation without exposing private tool output. The shared shutdown suite runs directly in Node.js, and the pure command-label helper has no installer runtime dependency. Terraform checks cover all three modules on both matrix versions; no wizard job or entry point is introduced here. The Hub image can resolve locked dependencies through an explicit npm proxy and prune runtime dependencies offline. Deployment guidance preserves the current GitHub sign-in and administrator-enrollment behavior while documenting manual configuration rather than promising a runnable wizard. Live Azure release, recovery, and proxy-backed Docker builds remain unverified. Existing Linux-only artifact filesystem tests fail on macOS before exercising storage; their code and tests are unchanged. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent d80dc1a commit dd2cbe1

31 files changed

Lines changed: 1854 additions & 102 deletions

File tree

‎.github/workflows/hub-infrastructure.yml‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,22 @@ defaults:
1414

1515
jobs:
1616
terraform:
17-
name: Terraform ${{ matrix.command }}
17+
name: Terraform ${{ matrix.version }} ${{ matrix.module }} ${{ matrix.command }}
1818
runs-on: ubuntu-latest
1919
strategy:
2020
fail-fast: false
2121
matrix:
22+
version: ["1.13.4", "1.17.1"]
23+
module: [".", "foundation", "provision"]
2224
command: ["fmt -check -recursive", "validate", "test"]
25+
defaults:
26+
run:
27+
working-directory: infrastructure/azure/${{ matrix.module }}
2328
steps:
2429
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2530
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
2631
with:
27-
terraform_version: 1.13.4
32+
terraform_version: ${{ matrix.version }}
2833
terraform_wrapper: false
2934
- run: terraform init -backend=false -input=false -lockfile=readonly
3035
- run: terraform ${{ matrix.command }}
@@ -37,4 +42,4 @@ jobs:
3742
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
3843
with:
3944
node-version: 24
40-
- run: node --test deploy-hub/index.test.ts
45+
- run: node --test deploy-hub/index.test.ts stop-hub/index.test.ts ../installer/command/describe/index.test.ts

‎hub/Dockerfile‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-cert
66
COPY package.json package-lock.json .npmrc ./
77
COPY schema ./schema
88
COPY prisma7.config.ts ./
9-
RUN npm ci --engine-strict
9+
ARG NPM_REGISTRY
10+
RUN if [ -n "$NPM_REGISTRY" ]; then \
11+
node -e 'const fs=require("node:fs"); const lock=JSON.parse(fs.readFileSync("package-lock.json","utf8")); for(const entry of Object.values(lock.packages)){delete entry.resolved} fs.writeFileSync("package-lock.json",JSON.stringify(lock))'; \
12+
export npm_config_registry="$NPM_REGISTRY"; \
13+
fi; \
14+
npm ci --engine-strict --no-audit --no-fund
1015
COPY . .
1116
RUN npm run build:runtime
1217

@@ -20,7 +25,7 @@ COPY --from=build /app/package.json /app/package-lock.json /app/.npmrc ./
2025
COPY --from=build /app/schema ./schema
2126
COPY --from=build /app/prisma7.config.ts ./
2227
COPY --from=build /app/node_modules ./node_modules
23-
RUN npm prune --omit=dev --ignore-scripts && npm cache clean --force
28+
RUN npm prune --omit=dev --ignore-scripts --offline && npm cache clean --force
2429
COPY --from=build /app/dist ./dist
2530
USER node
2631
EXPOSE 3001

‎hub/client/components/prototype-hub-connection-dialog/index.test.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ it("saves an edited URL before connecting and retains invalid drafts and save fa
217217
fireEvent.click(screen.getByRole("button", { name: "Save Hub" }))
218218
await screen.findByRole("link", { name: "https://new.example.com" })
219219
expect(showModal).toHaveBeenCalledOnce()
220-
expect(screen.getByRole("button", { name: "Edit Hub URL" })).toHaveFocus()
220+
await waitFor(() => {
221+
expect(screen.getByRole("button", { name: "Edit Hub URL" })).toHaveFocus()
222+
})
221223
expect(onSelectHub).toHaveBeenLastCalledWith("https://new.example.com")
222224
expect(screen.queryByRole("alert")).not.toBeInTheDocument()
223225
fireEvent.click(screen.getByRole("button", { name: "Connect to the Hub" }))

‎hub/docs/deployment.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ The Hub image runs the frontend, API, and both workers together. It can expose G
44

55
## Image and runtime
66

7-
Build from the repository root with `docker build -t replica-hub:check hub`. The image runs as a non-root user and contains compiled application code and migration tooling. It writes no application state to its writable layer. Publish and deploy the same image digest for setup and Hub.
7+
Build from the repository root with `docker build -t replica-hub:check hub`. When an npm proxy is required, add `--build-arg NPM_REGISTRY=https://YOUR_PROXY/`. This resolves locked dependency versions through that registry without changing the source lockfile; the registry URL must not contain credentials. The image runs as a non-root user and contains compiled application code and migration tooling. It writes no application state to its writable layer. Publish and deploy the same image digest for setup and Hub.
8+
9+
Host npm configuration is not inherited by the image build. Without `NPM_REGISTRY`, the container needs public npm access. Where that access is not allowed, supply your approved proxy using the build argument above. Explicit scoped registry mappings in the copied `.npmrc` still apply.
810

911
Publishing is an explicit operator step, not a side effect of CI. From the approved checkout, authenticate to an authorized registry, then run `docker buildx build --platform linux/amd64 --tag YOUR_REGISTRY/replica-hub:YOUR_COMMIT --push hub`. Resolve the published digest with `docker buildx imagetools inspect YOUR_REGISTRY/replica-hub:YOUR_COMMIT` and give deployment the `registry/repository@sha256:...` reference, never the mutable tag.
1012

@@ -53,7 +55,7 @@ The deployment orchestrator owns serialization of the complete release, includin
5355

5456
## Scope and evidence
5557

56-
CI checks the image against disposable PostgreSQL, including setup, frontend/API serving, readiness, and termination. This is not a supported local-production installation. The existing devcontainer remains the development environment.
58+
CI checks the image against disposable PostgreSQL, including setup, frontend/API serving, readiness, and termination. Set `NPM_REGISTRY` when running `node hub/script/check-image/index.ts` locally if the build requires a proxy. This is not a supported local-production installation. The existing devcontainer remains the development environment.
5759

5860
The [Azure reference installation](../../infrastructure/README.md) uses Terraform and a serialized maintenance-window release. It consumes the same image but does not yet configure the optional authentication settings. Add those protected settings and the exact Container Apps proxy-chain length before enabling authentication there.
5961

‎hub/script/check-image/index.ts‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,27 @@ export async function checkImage() {
3131
let applicationCreated = false
3232
let imageCreated = false
3333
try {
34-
execFileSync("docker", ["build", "-t", image, resolve(import.meta.dirname, "../..")], {
35-
stdio: "inherit",
36-
})
34+
const registry = process.env.NPM_REGISTRY
35+
if (registry) {
36+
const url = new URL(registry)
37+
assert(
38+
url.protocol === "https:" && !url.username && !url.password && !url.search && !url.hash,
39+
"NPM_REGISTRY must be an HTTPS URL without credentials, query, or fragment",
40+
)
41+
}
42+
execFileSync(
43+
"docker",
44+
[
45+
"build",
46+
"-t",
47+
image,
48+
...(registry ? ["--build-arg", `NPM_REGISTRY=${registry}`] : []),
49+
resolve(import.meta.dirname, "../.."),
50+
],
51+
{
52+
stdio: "inherit",
53+
},
54+
)
3755
imageCreated = true
3856
docker("network", "create", network)
3957
networkCreated = true

‎infrastructure/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.tools/
2+
node_modules/
3+
.local/
24
**/.terraform/
35
**/*.tfstate*
46
**/*.tfplan

0 commit comments

Comments
 (0)