api: バージョンとデプロイコミットを返す /version エンドポイントを追加
- package.jsonのversionとビルド時注入のコミットSHA(APP_COMMIT)を返す - CoolifyのSOURCE_COMMITをbuild argとして受けるためDockerfile/composeを更新 - authModeも含め、デプロイ状態の切り分けに使えるようにした
This commit is contained in:
@@ -2,6 +2,11 @@ FROM node:22-bookworm
|
|||||||
|
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
# Build-time commit SHA, injected by docker compose (SOURCE_COMMIT) or Coolify.
|
||||||
|
# Exposed to the API at /version for deploy diagnostics.
|
||||||
|
ARG APP_COMMIT=unknown
|
||||||
|
ENV APP_COMMIT=${APP_COMMIT}
|
||||||
|
|
||||||
# package-lock.json is committed, so npm ci installs the exact dependency tree.
|
# package-lock.json is committed, so npm ci installs the exact dependency tree.
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Fastify, { type FastifyReply, type FastifyRequest } from "fastify";
|
|||||||
import cookie from "@fastify/cookie";
|
import cookie from "@fastify/cookie";
|
||||||
import cors from "@fastify/cors";
|
import cors from "@fastify/cors";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import pkg from "../../../package.json" with { type: "json" };
|
||||||
import { buildSourceDocument } from "../../../packages/core/src/index";
|
import { buildSourceDocument } from "../../../packages/core/src/index";
|
||||||
import type { Identity } from "../../../packages/core/src/index";
|
import type { Identity } from "../../../packages/core/src/index";
|
||||||
import { loadConfig } from "./config";
|
import { loadConfig } from "./config";
|
||||||
@@ -85,6 +86,13 @@ export async function createServer() {
|
|||||||
await registerAuthRoutes(app, appConfig);
|
await registerAuthRoutes(app, appConfig);
|
||||||
|
|
||||||
app.get("/healthz", async () => ({ ok: true, service: "altdock-api", storageMode: appConfig.STORAGE_MODE }));
|
app.get("/healthz", async () => ({ ok: true, service: "altdock-api", storageMode: appConfig.STORAGE_MODE }));
|
||||||
|
app.get("/version", async () => ({
|
||||||
|
name: "altdock-api",
|
||||||
|
version: pkg.version,
|
||||||
|
commit: process.env.APP_COMMIT || process.env.SOURCE_COMMIT || "unknown",
|
||||||
|
authMode: appConfig.AUTH_MODE,
|
||||||
|
node: process.version,
|
||||||
|
}));
|
||||||
|
|
||||||
app.get("/api/v1/me", async (request, reply) => {
|
app.get("/api/v1/me", async (request, reply) => {
|
||||||
const identity = await requireIdentity(request, reply, appConfig);
|
const identity = await requireIdentity(request, reply, appConfig);
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ x-altdock-app: &altdock-app
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
# Coolify provides SOURCE_COMMIT at build time; falls back to unknown.
|
||||||
|
APP_COMMIT: ${SOURCE_COMMIT:-unknown}
|
||||||
working_dir: /workspace
|
working_dir: /workspace
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user