forked from jzakotnik/openlibry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (60 loc) · 2.47 KB
/
Copy pathDockerfile
File metadata and controls
72 lines (60 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# ---- Base image versions ----
FROM node:22-alpine AS base
RUN apk add --no-cache libc6-compat openssl
WORKDIR /app
# ---- Dependencies (cacheable, prod only) ----
FROM base AS deps
COPY package.json ./
COPY package-lock.json ./
RUN npm install -g npm@11.6.4
RUN echo "=== BUILDING WITH UPDATED DOCKERFILE ===" && npm --version
RUN echo "=== FILES COPIED ===" && ls -la
# Avoid dev deps here so Cypress doesn't run in this layer
RUN npm install --ignore-scripts
# ---- Builder (needs dev deps, but skip Cypress binary) ----
FROM base AS builder
ENV CYPRESS_INSTALL_BINARY=0
ENV DATABASE_URL="file:./dummy.db"
COPY package.json ./
COPY package-lock.json ./
RUN npm install -g npm@11.6.4
RUN echo "=== BUILDING WITH UPDATED DOCKERFILE ===" && npm --version
RUN echo "=== FILES COPIED ===" && ls -la
RUN npm install
COPY . .
# Generate Prisma Client at build time
RUN npx prisma generate
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
# ---- Runner (slim) ----
FROM base AS runner
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
# Your DB is bind-mounted here from the host
ENV DATABASE_URL="file:/app/database/dev.db"
# Copy runtime artifacts (Next.js standalone output recommended)
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
COPY --from=builder /app/prisma ./prisma
# Prisma 7 config file for CLI commands (migrate deploy, db push)
COPY --from=builder /app/prisma.config.mjs ./
# Default label sheet/template definitions shipped with the image.
# The entrypoint seeds these into database/custom/labels/ on first run
# (existing files are never overwritten, so school customisations survive).
COPY --from=builder /app/database/custom/labels /app/defaults/labels
# Ensure DB directory exists and fix perms
RUN mkdir -p /app/database && chown -R node:node /app
# Add entrypoint that runs Prisma schema sync on first run / on pending migrations
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Make Prisma CLI available at runtime via node_modules from builder (lightweight)
# We copy only what's needed for npx to find prisma: package.json, lockfile and node_modules/prisma*
# If your devDeps are heavy, you can replace this with: RUN npm i -g prisma@6.13.0
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
USER node
EXPOSE 3000
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "server.js"]