sowedo
sowedo•3d ago

Docker + Turbo + PNPM + Convex

Has anyone been able to get your app (web rr7) running in a docker container? I am getting a lot of module resolution errors at build time. In the dev environment it runs perfectly fine .. I am curious if anyone has an example repo?
3 Replies
Convex Bot
Convex Bot•3d ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Clever Tagline
Clever Tagline•3d ago
I fought through that battle a few weeks ago. Unfortunately it's for a work project, so I can't share the repo, but I can try to help anyway. Let me dig up the dockerfile that I ended up using...
# syntax=docker/dockerfile:1
FROM node:latest AS base

ENV CONVEX_URL=https://your-convex-url.convex.cloud

FROM base AS builder
# Set working directory
WORKDIR /app
RUN npm install -g turbo@^2.4.2
COPY . .

# Generate a partial monorepo with a pruned lockfile for a target workspace.
RUN turbo prune staff-portal --docker

# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
WORKDIR /app

# First install the dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
RUN npm install

# Build the project
COPY --from=builder /app/out/full/ .
RUN npx turbo run build

FROM base AS runner

COPY --from=installer . .
COPY --from=installer ./app/apps/staff-portal/build/client/ ./build/client/
RUN npm install -g @react-router/serve@7.6.3

CMD ["react-router-serve", "/app/apps/staff-portal/build/server/index.js"]
# syntax=docker/dockerfile:1
FROM node:latest AS base

ENV CONVEX_URL=https://your-convex-url.convex.cloud

FROM base AS builder
# Set working directory
WORKDIR /app
RUN npm install -g turbo@^2.4.2
COPY . .

# Generate a partial monorepo with a pruned lockfile for a target workspace.
RUN turbo prune staff-portal --docker

# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
WORKDIR /app

# First install the dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
RUN npm install

# Build the project
COPY --from=builder /app/out/full/ .
RUN npx turbo run build

FROM base AS runner

COPY --from=installer . .
COPY --from=installer ./app/apps/staff-portal/build/client/ ./build/client/
RUN npm install -g @react-router/serve@7.6.3

CMD ["react-router-serve", "/app/apps/staff-portal/build/server/index.js"]
apps/staff-portal is the root folder for the app in my case. The Convex stuff is in packages/backend/convex Let me know if that gets you anywhere. FWIW I'm still really green with Docker, and it took help from the Docker forum to get this far.
sowedo
sowedoOP•3d ago
really appreciate it! I'll have a look at it, thanks man 🙂

Did you find this page helpful?