Enhance Dockerfile and Redis configuration for improved build-time handling

- Added environment variables in Dockerfile for build-time placeholders, ensuring proper static analysis during the build process.
- Updated Redis initialization in redis.ts to include lazy connection, preventing network access during module import and improving error handling with a console log for connection errors.
This commit is contained in:
smueller
2026-07-22 14:15:52 +02:00
parent 6a155597ce
commit 59b3ccb0ca
2 changed files with 32 additions and 2 deletions

View File

@@ -17,6 +17,25 @@ COPY eslint.config.js .eslintrc.cjs .prettierrc ./
RUN pnpm install --frozen-lockfile=false
RUN pnpm --filter @nexumi/shared build
RUN pnpm --filter @nexumi/webui prisma:generate
# `next build` statically evaluates route/module code while collecting page
# data. Our env schema and Prisma client are validated eagerly at import
# time, so the build needs *some* well-formed values even though no real
# secrets or network access are available at build time. These placeholders
# are only used for that static analysis step and are always overridden by
# the real values from `.env` (via docker-compose `env_file`) at container
# start, since this ENV only applies to this intermediate build stage and is
# never copied into the `runner` stage / final image.
# Note: this intentionally triggers a "SecretsUsedInArgOrEnv" lint warning
# because of the variable names — the values below are non-sensitive
# placeholders, not real secrets.
ENV NODE_ENV=production \
DATABASE_URL=postgresql://build:build@localhost:5432/build \
REDIS_URL=redis://localhost:6379 \
BOT_CLIENT_ID=0000000000000000000 \
BOT_CLIENT_SECRET=build-time-placeholder \
WEBUI_URL=http://localhost:3000 \
SESSION_SECRET=build-time-placeholder-session-secret-32chars \
DEFAULT_LOCALE=de
RUN pnpm --filter @nexumi/webui build
FROM base AS runner