Enhance environment variable handling and Dockerfile configuration
- Introduced a utility function to preprocess environment variables, converting empty strings, undefined, or null values to undefined for better validation in EnvSchema. - Updated Dockerfile to set PORT and HOSTNAME environment variables for improved container configuration. - Revised PHASE-TRACKING.md to include automated deployment verification steps, ensuring a smoother deployment process.
This commit is contained in:
@@ -3,11 +3,14 @@ import { z } from 'zod';
|
|||||||
|
|
||||||
config();
|
config();
|
||||||
|
|
||||||
|
const emptyToUndefined = (value: unknown) =>
|
||||||
|
value === '' || value === undefined || value === null ? undefined : value;
|
||||||
|
|
||||||
const EnvSchema = z.object({
|
const EnvSchema = z.object({
|
||||||
NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),
|
NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),
|
||||||
BOT_TOKEN: z.string().min(1),
|
BOT_TOKEN: z.string().min(1),
|
||||||
BOT_CLIENT_ID: z.string().min(1),
|
BOT_CLIENT_ID: z.string().min(1),
|
||||||
BOT_GUILD_ID: z.string().min(1).optional(),
|
BOT_GUILD_ID: z.preprocess(emptyToUndefined, z.string().min(1).optional()),
|
||||||
DATABASE_URL: z.string().url(),
|
DATABASE_URL: z.string().url(),
|
||||||
REDIS_URL: z.string().url(),
|
REDIS_URL: z.string().url(),
|
||||||
LOG_LEVEL: z.string().default('info'),
|
LOG_LEVEL: z.string().default('info'),
|
||||||
@@ -15,11 +18,11 @@ const EnvSchema = z.object({
|
|||||||
BACKUP_RETENTION_DAYS: z.coerce.number().int().positive().default(14),
|
BACKUP_RETENTION_DAYS: z.coerce.number().int().positive().default(14),
|
||||||
BACKUP_CRON: z.string().default('0 3 * * *'),
|
BACKUP_CRON: z.string().default('0 3 * * *'),
|
||||||
BACKUP_DIR: z.string().default('/backups'),
|
BACKUP_DIR: z.string().default('/backups'),
|
||||||
METRICS_TOKEN: z.string().optional(),
|
METRICS_TOKEN: z.preprocess(emptyToUndefined, z.string().min(1).optional()),
|
||||||
HEALTH_PORT: z.coerce.number().int().positive().default(8080),
|
HEALTH_PORT: z.coerce.number().int().positive().default(8080),
|
||||||
PUBLIC_BASE_URL: z.string().url().default('http://localhost:8080'),
|
PUBLIC_BASE_URL: z.string().url().default('http://localhost:8080'),
|
||||||
TWITCH_CLIENT_ID: z.string().min(1).optional(),
|
TWITCH_CLIENT_ID: z.preprocess(emptyToUndefined, z.string().min(1).optional()),
|
||||||
TWITCH_CLIENT_SECRET: z.string().min(1).optional()
|
TWITCH_CLIENT_SECRET: z.preprocess(emptyToUndefined, z.string().min(1).optional())
|
||||||
});
|
});
|
||||||
|
|
||||||
export const env = EnvSchema.parse(process.env);
|
export const env = EnvSchema.parse(process.env);
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ RUN pnpm --filter @nexumi/webui build
|
|||||||
|
|
||||||
FROM base AS runner
|
FROM base AS runner
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
ENV PORT=3000
|
||||||
|
ENV HOSTNAME=0.0.0.0
|
||||||
COPY --from=build /app/apps/webui/.next/standalone ./
|
COPY --from=build /app/apps/webui/.next/standalone ./
|
||||||
COPY --from=build /app/apps/webui/.next/static ./apps/webui/.next/static
|
COPY --from=build /app/apps/webui/.next/static ./apps/webui/.next/static
|
||||||
COPY --from=build /app/apps/webui/public ./apps/webui/public
|
COPY --from=build /app/apps/webui/public ./apps/webui/public
|
||||||
|
|||||||
@@ -220,12 +220,17 @@ Dieses Dokument hält den aktuellen Implementierungsstand fest. Es wird bei jede
|
|||||||
|
|
||||||
### Manuelle Tests (noch offen)
|
### Manuelle Tests (noch offen)
|
||||||
|
|
||||||
- Discord Developer Portal: OAuth2-Redirect `http://localhost:3000/api/auth/callback` (bzw. `https://nexumi.de/api/auth/callback` in Produktion) unter „OAuth2 → Redirects" eintragen; Scopes `identify guilds` sind Standard-OAuth2-Scopes, keine Extra-Freigabe nötig
|
- Discord Developer Portal: OAuth2-Redirect `http://localhost:3000/api/auth/callback` (bzw. `https://nexumi.de/api/auth/callback` in Produktion) unter „OAuth2 → Redirects" eintragen
|
||||||
- Login-Flow Ende-zu-Ende gegen echten Discord-Account testen (`/login` → Discord-Consent → `/dashboard`)
|
- Login-Flow Ende-zu-Ende (`http://localhost:3000/login` → Discord → `/dashboard`)
|
||||||
- Dashboard-Zugriff mit einem Account ohne „Server verwalten"-Recht prüfen (muss auf `/dashboard` zurückspringen)
|
- Zugriff ohne „Server verwalten" prüfen
|
||||||
- Modul-Toggles je Modul speichern und in der Bot-DB/Redis verifizieren (insbesondere Fun `enabled` und den neuen Redis-Hash `dashboard:modules:{guildId}`)
|
- Modul-Toggles + Access-Rules speichern; Audit-Log prüfen
|
||||||
- Access-Rules anlegen/löschen und Dashboard-Audit-Log-Einträge in der DB prüfen
|
|
||||||
- `docker compose up -d --build webui` gegen laufenden Postgres/Redis-Stack verifizieren
|
### Deploy-Verifikation (automatisiert)
|
||||||
|
|
||||||
|
- `docker compose up -d --build bot webui` OK
|
||||||
|
- Migration `20260722180000_phase6_webui` angewendet (`DashboardAccessRule`, `DashboardAuditLog`, `GuildSettings.timezone`)
|
||||||
|
- Bot healthy + ready; WebUI healthy (`/api/health` → `{"ok":true}`), Login-Seite erreichbar
|
||||||
|
- Checks: shared tests 23, webui typecheck/lint/test grün
|
||||||
|
|
||||||
## Nächster geplanter Schritt
|
## Nächster geplanter Schritt
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user