Skip to content

Commit b51ff0e

Browse files
committed
🔄 Synced local '.' with remote 'apps/examples/nextjs'
1 parent cbf1a43 commit b51ff0e

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

Dockerfile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# syntax=docker/dockerfile-upstream:master-labs
2+
3+
# Loosely based on Next.js Dockerfile example - https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
4+
FROM node:20-slim AS base
5+
6+
# Install package manager
7+
RUN --mount=type=cache,id=pnpm-auth-store,target=/root/.pnpm-store \
8+
npm i --global --no-update-notifier --no-fund pnpm@latest
9+
10+
USER node
11+
12+
## DEPENDENCIES
13+
FROM base AS deps
14+
WORKDIR /app
15+
16+
# Copy over package.json and lock files
17+
# - "--parents" flag required otherwise copying "patches" only copies the contents
18+
# of that directory, and not the directory itself. This requires the syntax
19+
# directive at the top of the file.
20+
COPY --parents --chown=node:node pnpm-lock.yaml pnpm-workspace.yaml patches ./
21+
COPY --chown=node:node apps/examples/nextjs-docker/package.json ./package.json
22+
23+
# Avoid 'cross-device link not permitted' error with pnpm install
24+
RUN echo "package-import-method=copy" > .npmrc
25+
26+
# Install dependencies
27+
RUN --mount=type=cache,id=pnpm-auth-store,target=/root/.pnpm-store pnpm install
28+
29+
## BUILDER
30+
FROM base AS builder
31+
WORKDIR /app
32+
33+
# Copy code from the examples app
34+
COPY --chown=node:node apps/examples/nextjs-docker ./
35+
# Copy dependencies from deps stage
36+
COPY --from=deps /app ./
37+
38+
# ENV NEXT_TELEMETRY_DISABLED 1
39+
ENV NODE_ENV production
40+
41+
# Build the "standalone" Next.js version
42+
RUN pnpm build
43+
# Remove node_modules
44+
RUN rm -rf node_modules
45+
46+
## RUNNER
47+
FROM base AS runner
48+
WORKDIR /app
49+
50+
ENV NODE_ENV production
51+
# ENV NEXT_TELEMETRY_DISABLED 1
52+
53+
# Copy everything from builder stage
54+
COPY --chown=node:node --from=builder /app ./
55+
56+
# Install only prod dependencies
57+
RUN --mount=type=cache,id=pnpm-auth-store,target=/root/.pnpm-store pnpm install --prod
58+
RUN --mount=type=cache,id=pnpm-auth-store,target=/root/.pnpm-store pnpm install -w sharp
59+
60+
USER node
61+
EXPOSE 3000
62+
ENV PORT 3000
63+
64+
# Run the built project
65+
CMD ["pnpm", "exec", "next", "start"]

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: "3"
2+
3+
services:
4+
authjs-docker-test:
5+
environment:
6+
- TEST_KEYCLOAK_USERNAME
7+
- TEST_KEYCLOAK_PASSWORD
8+
- AUTH_KEYCLOAK_ID
9+
- AUTH_KEYCLOAK_SECRET
10+
- AUTH_KEYCLOAK_ISSUER
11+
- AUTH_SECRET="MohY0/2zSQw/psWEnejC2ka3Al0oifvY4YjOkUaFfnI="
12+
- AUTH_URL=http://localhost:3000/auth
13+
build:
14+
context: ../../../
15+
dockerfile: apps/examples/nextjs-docker/Dockerfile
16+
ports:
17+
- "3000:3000"

0 commit comments

Comments
 (0)