Skip to content

Instantly share code, notes, and snippets.

@darrylmorley
Created October 1, 2021 05:50
Show Gist options
  • Save darrylmorley/fa909f1627818dacc0058c3dcc5bf6f3 to your computer and use it in GitHub Desktop.
Save darrylmorley/fa909f1627818dacc0058c3dcc5bf6f3 to your computer and use it in GitHub Desktop.
NextJS Docker with Prisma
Dockerfile changes:
# Install dependencies only when needed
FROM node:14-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock ./
**COPY ./prisma/schema.prisma ./prisma/schema.prisma**
RUN yarn install --frozen-lockfile
# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
**ENV DATABASE_URL Your_Database_URL**
package.json changes:
"scripts": {
"dev": "next dev",
"build": "next build",
**"postinstall": "prisma generate",**
"start": "next start -p ${PORT:=3000}"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment