Docker compose cannot get nextjs app online cause standalone folder is not found (pnpm)
Unanswered
Amur catfish posted this in #help-forum
Amur catfishOP
Hi, I am trying to get my Next.js app inside my turborepo deployed with docker, but it keeps saying the standalone folder is not found.
Output is set to 'standalone' in nextjs.config.js
Dockerfile:
Output is set to 'standalone' in nextjs.config.js
Dockerfile:
FROM node:alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
FROM base AS builder
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
# Replace <your-major-version> with the major version installed in your repository. For example:
# RUN yarn global add turbo@^2
RUN pnpm add -g turbo@^2
COPY . .
# Generate a partial monorepo with a pruned lockfile for a target workspace.
# Assuming "web" is the name entered in the project's package.json: { name: "web" }
RUN turbo prune web --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app
# First install the dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
RUN pnpm install
# Build the project
COPY --from=builder /app/out/full/ .
RUN pnpm turbo run build --filter=web...
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
USER nextjs
CMD node apps/web/server.js
1 Reply
Amur catfishOP
docker-compose.yml
services:
api:
restart: always
build:
context: .
dockerfile: ./apps/api/Dockerfile
depends_on:
- redis
links:
- redis
environment:
- REDIS_URL=redis://redis:6379
- NODE_ENV=production
ports:
- 3000:3000
web:
restart: always
build:
context: .
dockerfile: ./apps/web/Dockerfile
depends_on:
- api
environment:
- NODE_ENV=production
ports:
- 3001:3001
redis:
image: redis:latest
restart: always
ports:
- '6379:6379'