Skip to content

Commit f5fa55b

Browse files
committed
working docker build
1 parent 262dc82 commit f5fa55b

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dockerfile
2+
.dockerignore
3+
node_modules
4+
npm-debug.log
5+
README.md
6+
.next
7+
.git

Dockerfile

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,48 @@ FROM base AS deps
66
RUN apk add --no-cache libc6-compat
77
WORKDIR /app
88

9-
# Install dependencies based on the preferred package manager
10-
COPY package.json pnpm-lock.yaml ./
119

12-
# Install pnpm
13-
RUN npm install -g pnpm
10+
# Prisma stuff
11+
COPY prisma ./prisma
1412

15-
COPY . .
13+
# Install dependencies
14+
COPY package.json pnpm-lock.yaml* .env ./
15+
RUN pnpm i --frozen-lockfile
1616

17-
# Install dependencies using pnpm
18-
RUN pnpm install
1917

2018
# Rebuild the source code only when needed
2119
FROM base AS builder
20+
WORKDIR /app
2221
COPY --from=deps /app/node_modules ./node_modules
2322
COPY . .
2423

25-
RUN npm install -g pnpm
26-
27-
RUN pnpm -v
24+
# Next.js collects completely anonymous telemetry data about general usage.
25+
# Learn more here: https://nextjs.org/telemetry
26+
# Uncomment the following line in case you want to disable telemetry during the build.
27+
# ENV NEXT_TELEMETRY_DISABLED 1
2828

2929
RUN pnpm run build
3030

31+
# If using npm comment out above and use below instead
32+
# RUN npm run build
33+
3134
# Production image, copy all the files and run next
3235
FROM base AS runner
3336
WORKDIR /app
3437

3538
ENV NODE_ENV production
36-
3739
# Uncomment the following line in case you want to disable telemetry during runtime.
3840
# ENV NEXT_TELEMETRY_DISABLED 1
3941

4042
RUN addgroup --system --gid 1001 nodejs
4143
RUN adduser --system --uid 1001 nextjs
4244

4345
COPY --from=builder /app/public ./public
44-
COPY --from=builder /app/package.json ./package.json
46+
47+
# Set the correct permission for prerender cache
48+
RUN mkdir .next
49+
RUN chown nextjs:nodejs .next
50+
4551
# Automatically leverage output traces to reduce image size
4652
# https://nextjs.org/docs/advanced-features/output-file-tracing
4753
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
@@ -52,5 +58,7 @@ USER nextjs
5258
EXPOSE 3000
5359

5460
ENV PORT 3000
61+
# set hostname to localhost
62+
ENV HOSTNAME "0.0.0.0"
5563

5664
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)