Phase0
Some checks failed
CI / Node — lint, typecheck, test, build (push) Failing after 9s
CI / Go — node-agent tests (push) Failing after 22s
CI / Go — edge-gateway build (push) Successful in 13s

This commit is contained in:
smueller
2026-06-26 11:12:51 +02:00
parent e25e871067
commit 4fe25e6ec3
106 changed files with 1002 additions and 160 deletions

View File

@@ -1,19 +1,31 @@
FROM node:22-alpine AS builder
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
COPY package.json pnpm-workspace.yaml turbo.json ./
COPY apps/api/package.json apps/api/
RUN pnpm install --filter @hexahost/api...
COPY apps/api apps/api
RUN pnpm --filter @hexahost/api build
# syntax=docker/dockerfile:1
FROM node:22-alpine
FROM node:22-alpine AS base
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
WORKDIR /app
FROM base AS builder
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
COPY packages packages
COPY apps/api apps/api
RUN pnpm install --frozen-lockfile
RUN pnpm --filter @hexahost/api... build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV API_PORT=3001
COPY --from=builder /app/apps/api/dist ./dist
COPY --from=builder /app/apps/api/package.json ./
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-lock.yaml ./
COPY --from=builder /app/pnpm-workspace.yaml ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/apps/api/dist ./apps/api/dist
COPY --from=builder /app/apps/api/package.json ./apps/api/package.json
WORKDIR /app/apps/api
EXPOSE 3001
HEALTHCHECK --interval=15s --timeout=5s --retries=3 \
CMD wget -qO- http://localhost:3001/healthz || exit 1
CMD wget -qO- http://localhost:3001/api/v1/health/live || exit 1
CMD ["node", "dist/main.js"]

View File

@@ -2,12 +2,18 @@ import { describe, it } from "node:test";
import assert from "node:assert/strict";
import http from "node:http";
describe("api health", () => {
it("returns ok for healthz", async () => {
describe("api health contract", () => {
it("returns ok for liveness-style health response", async () => {
const server = http.createServer((req, res) => {
if (req.url === "/healthz") {
if (req.url === "/api/v1/health/live") {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({ status: "ok", service: "api" }));
res.end(
JSON.stringify({
status: "ok",
service: "api",
timestamp: new Date().toISOString(),
}),
);
return;
}
res.writeHead(404);
@@ -19,10 +25,11 @@ describe("api health", () => {
assert.ok(addr && typeof addr === "object");
const port = addr.port;
const response = await fetch(`http://127.0.0.1:${port}/healthz`);
const response = await fetch(`http://127.0.0.1:${port}/api/v1/health/live`);
assert.equal(response.status, 200);
const body = (await response.json()) as { status: string };
const body = await response.json();
assert.equal(body.status, "ok");
assert.equal(body.service, "api");
await new Promise((resolve, reject) =>
server.close((err) => (err ? reject(err) : resolve())),

File diff suppressed because one or more lines are too long

View File

@@ -1,20 +1,31 @@
FROM node:22-alpine AS builder
WORKDIR /app
# syntax=docker/dockerfile:1
FROM node:22-alpine AS base
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
COPY package.json pnpm-workspace.yaml turbo.json ./
COPY apps/web/package.json apps/web/
RUN pnpm install --filter @hexahost/web...
WORKDIR /app
FROM base AS builder
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
COPY packages packages
COPY apps/web apps/web
RUN pnpm install --frozen-lockfile
ENV DOCKER_BUILD=1
RUN pnpm --filter @hexahost/web build
FROM node:22-alpine
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV WEB_PORT=3000
COPY --from=builder /app/apps/web/dist ./dist
COPY --from=builder /app/apps/web/public ./public
COPY --from=builder /app/apps/web/package.json ./
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs
COPY --from=builder /app/apps/web/public ./apps/web/public
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
USER nextjs
EXPOSE 3000
HEALTHCHECK --interval=15s --timeout=5s --retries=3 \
CMD wget -qO- http://localhost:3000/api/health || exit 1
CMD ["node", "dist/server.js"]
CMD wget -qO- http://localhost:3000/de || exit 1
CMD ["node", "apps/web/server.js"]

View File

@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

View File

@@ -1,9 +1,18 @@
import type { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin";
import path from "node:path";
const withNextIntl = createNextIntlPlugin("./src/i18n/request.ts");
const isDockerBuild = process.env.DOCKER_BUILD === "1";
const nextConfig: NextConfig = {
...(isDockerBuild
? {
output: "standalone" as const,
outputFileTracingRoot: path.join(__dirname, "../.."),
}
: {}),
transpilePackages: ["@hexahost/ui"],
};

View File

@@ -1,49 +0,0 @@
import http from "node:http";
import fs from "node:fs";
import path from "node:path";
const port = Number(process.env.WEB_PORT ?? process.env.PORT ?? 3000);
const appName = process.env.APP_NAME ?? "HexaHost GameCloud";
const publicDir = path.join(process.cwd(), "public");
const indexHtml = `<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>${appName}</title>
</head>
<body>
<main>
<h1>${appName}</h1>
<p>Phase 0 — Web stub. Next.js UI arrives in Phase 1.</p>
</main>
</body>
</html>`;
const server = http.createServer((req, res) => {
if (req.url === "/api/health") {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({ status: "ok", service: "web", phase: "0" }));
return;
}
if (req.url === "/" || req.url === "/index.html") {
const filePath = path.join(publicDir, "index.html");
if (fs.existsSync(filePath)) {
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
fs.createReadStream(filePath).pipe(res);
return;
}
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
res.end(indexHtml);
return;
}
res.writeHead(404, { "Content-Type": "application/json" });
res.end(JSON.stringify({ status: "not_found" }));
});
server.listen(port, () => {
console.log(JSON.stringify({ level: "info", msg: "web listening", port }));
});

File diff suppressed because one or more lines are too long

View File

@@ -1,15 +1,31 @@
FROM node:22-alpine AS builder
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
COPY package.json pnpm-workspace.yaml turbo.json ./
COPY apps/worker/package.json apps/worker/
RUN pnpm install --filter @hexahost/worker...
COPY apps/worker apps/worker
RUN pnpm --filter @hexahost/worker build
# syntax=docker/dockerfile:1
FROM node:22-alpine
FROM node:22-alpine AS base
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
WORKDIR /app
FROM base AS builder
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
COPY packages packages
COPY apps/worker apps/worker
RUN pnpm install --frozen-lockfile
RUN pnpm --filter @hexahost/worker... build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/apps/worker/dist ./dist
COPY --from=builder /app/apps/worker/package.json ./
CMD ["node", "dist/main.js"]
ENV WORKER_PORT=3002
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-lock.yaml ./
COPY --from=builder /app/pnpm-workspace.yaml ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/apps/worker/dist ./apps/worker/dist
COPY --from=builder /app/apps/worker/package.json ./apps/worker/package.json
WORKDIR /app/apps/worker
EXPOSE 3002
HEALTHCHECK --interval=15s --timeout=5s --retries=3 \
CMD wget -qO- http://localhost:3002/health || exit 1
CMD ["node", "dist/index.js"]