mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 11:58:14 +00:00
a80086ef72
`docker compose up` now works with no .env editing. A new entrypoint (docker-entrypoint.sh) generates any missing secret (BETTER_AUTH_SECRET, AI_CREDENTIALS_KEY) on first start and persists it to the temetro_secrets volume, so values stay stable across restarts (rotating them would log users out / invalidate stored AI keys). Real values passed via .env/compose still win. This also fixes the boot failure where the compose backend ran with NODE_ENV=production but never passed AI_CREDENTIALS_KEY through, tripping the production guard. The secret is now an optional pass-through and BETTER_AUTH_SECRET no longer hard-fails when unset. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
28 lines
1.1 KiB
Docker
28 lines
1.1 KiB
Docker
# --- build stage: compile TypeScript -> dist ------------------------------
|
|
FROM node:22-alpine AS build
|
|
WORKDIR /app
|
|
COPY package*.json ./
|
|
# --ignore-scripts skips native postinstall builds (e.g. better-sqlite3, a
|
|
# dev-only dependency of @better-auth/cli that needs Python/node-gyp). The build
|
|
# step is just `tsc`, which needs no compiled binaries, and better-sqlite3 is
|
|
# never used at runtime (the prod stage omits dev deps).
|
|
RUN npm ci --ignore-scripts
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# --- runtime stage: prod deps only -----------------------------------------
|
|
FROM node:22-alpine AS runtime
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
COPY package*.json ./
|
|
RUN npm ci --omit=dev
|
|
COPY --from=build /app/dist ./dist
|
|
COPY --from=build /app/drizzle ./drizzle
|
|
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
EXPOSE 4000
|
|
# The entrypoint auto-generates any missing secrets, then we apply migrations
|
|
# and start the API.
|
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
|
CMD ["sh", "-c", "node dist/migrate.js && node dist/index.js"]
|