Refactor Study Desk application structure

This commit is contained in:
Elijah 2026-08-07 19:31:23 -07:00
parent faaccf8a7e
commit 089439ed90
145 changed files with 8087 additions and 3412 deletions

View file

@ -1,11 +1,19 @@
# ---- base ----
FROM node:22-slim AS base
RUN apt-get update -y && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
# ---- deps ----
FROM node:22-slim AS deps
FROM base AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
RUN npm ci
# ---- production dependencies ----
FROM deps AS runtime-deps
RUN npm prune --omit=dev
# ---- builder ----
FROM node:22-slim AS builder
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
@ -13,13 +21,13 @@ RUN npx prisma generate
RUN npm run build
# ---- runner ----
FROM node:22-slim AS runner
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3726
ENV HOSTNAME=0.0.0.0
ENV DATABASE_URL="file:/app/data/study.db"
RUN apt-get update -y && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
RUN useradd --system --create-home appuser && mkdir -p /app/data && chown -R appuser:appuser /app
COPY --from=builder /app/.next/standalone ./
@ -27,10 +35,13 @@ COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/prisma.config.ts ./
RUN npm install prisma@^7.8.0
COPY --from=builder /app/scripts ./scripts
COPY --from=runtime-deps /app/node_modules ./node_modules
COPY docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
# Running as root to avoid permission denied on Unraid host-mounted volumes
EXPOSE 3726
VOLUME ["/app/data"]
HEALTHCHECK --interval=10s --timeout=5s --start-period=20s --retries=6 \
CMD ["node", "-e", "fetch('http://127.0.0.1:3726/api/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]
ENTRYPOINT ["./docker-entrypoint.sh"]