Turbo setup with prisma and pnpm
I have a setup using turborepo and running a few apps and some shared packages together and it works well in dev but i can't figure out how to setup docker, pnpm and prisma together. I've written my dockerfile below and my tree structure is
Prisma;
/apps/qrtag/prisma/prisma.schema
/apps/qrtag/(nextjs app)
/apps/qrtag/Dockerfile
/docker-compose.yml
Dockkerfile
docker-compose.yml
.dockerignore
# Builder
FROM node:alpine AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
RUN yarn global add turbo
COPY . .
COPY /apps/qrtag/prisma ./
RUN turbo prune --scope=qrtag --docker
# Installer
FROM node:alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
RUN yarn global add pnpm
RUN yarn global add turbo
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN pnpm fetch
RUN pnpm install --offline
RUN pnpx prisma generate
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM
# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN
RUN turbo build --filter=qrtag...
# Runner
FROM node:alpine AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=installer /app/apps/qrtag/next.config.js .
COPY --from=installer /app/apps/qrtag/package.json .
# 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/qrtag/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/qrtag/.next/static ./apps/qrtag/.next/static
# COPY --from=installer --chown=nextjs:nodejs /app/apps/appname/public ./apps/appname/public
CMD node apps/qrtag/server.js
# Builder
FROM node:alpine AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
RUN yarn global add turbo
COPY . .
COPY /apps/qrtag/prisma ./
RUN turbo prune --scope=qrtag --docker
# Installer
FROM node:alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
RUN yarn global add pnpm
RUN yarn global add turbo
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN pnpm fetch
RUN pnpm install --offline
RUN pnpx prisma generate
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM
# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN
RUN turbo build --filter=qrtag...
# Runner
FROM node:alpine AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=installer /app/apps/qrtag/next.config.js .
COPY --from=installer /app/apps/qrtag/package.json .
# 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/qrtag/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/qrtag/.next/static ./apps/qrtag/.next/static
# COPY --from=installer --chown=nextjs:nodejs /app/apps/appname/public ./apps/appname/public
CMD node apps/qrtag/server.js
version: '3.8'
services:
mysql:
image: mysql:5.7
restart: always
ports:
- 3306:3306
expose:
- 3306
environment:
MYSQL_ROOT_PASSWORD: prisma
MYSQL_PASSWORD: prisma
MYSQL_USER: prisma
MYSQL_DATABASE: qrtag
volumes:
- mysql:/var/lib/mysql
app:
container_name: qrtag
build:
context: .
dockerfile: ./apps/qrtag/Dockerfile
ports:
- '3001:3001'
volumes:
mysql: ~
version: '3.8'
services:
mysql:
image: mysql:5.7
restart: always
ports:
- 3306:3306
expose:
- 3306
environment:
MYSQL_ROOT_PASSWORD: prisma
MYSQL_PASSWORD: prisma
MYSQL_USER: prisma
MYSQL_DATABASE: qrtag
volumes:
- mysql:/var/lib/mysql
app:
container_name: qrtag
build:
context: .
dockerfile: ./apps/qrtag/Dockerfile
ports:
- '3001:3001'
volumes:
mysql: ~
**/node_modules
node_modules
**/node_modules
node_modules
1 Reply
?