-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathDockerfile.dev
More file actions
38 lines (31 loc) · 1.31 KB
/
Copy pathDockerfile.dev
File metadata and controls
38 lines (31 loc) · 1.31 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
# Dev-mode Next.js runner — used by docker-compose.yml so the whole
# stack can come up with one `docker compose up`. Production builds use
# the multi-stage Dockerfile instead.
FROM node:20-alpine
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Use Chinese npm mirror for faster installs from CN networks
RUN npm config set registry https://registry.npmmirror.com/
# Install deps first (cached across code-only changes). Source is
# bind-mounted at runtime so we re-`npm install` automatically if
# package.json changes (entrypoint below).
COPY package.json package-lock.json* ./
RUN npm ci --ignore-scripts || npm install --ignore-scripts
# Generate Prisma client at startup so schema changes take effect on
# restart without rebuilding the image.
EXPOSE 3100
ENV PORT=3100
ENV HOSTNAME=0.0.0.0
ENV NEXT_TELEMETRY_DISABLED=1
# Entrypoint:
# 1) If host package.json differs from baked one, sync deps
# 2) Regenerate Prisma client (cheap if unchanged)
# 3) Run `next dev` on 0.0.0.0:3100 with turbopack
CMD ["sh", "-c", "\
if ! cmp -s /app/package.json /app/.baked-package.json 2>/dev/null; then \
echo 'package.json changed → re-installing deps'; \
npm install --ignore-scripts && cp /app/package.json /app/.baked-package.json; \
fi; \
npx prisma generate && \
npx next dev --turbopack --port 3100 --hostname 0.0.0.0\
"]