Last fall I began working on an app using Remix inside a Turborepo monorepo. Once React Router 7 came out, I switched the app to that. Local development has been pretty smooth so far, and after hitting some snags deploying directly to DigitalOcean, I thought that Iād take Docker for a spin. I first took a basic RR app, made an image, and deployed it via DigitalOceanās container registry without any issues. However, Iām hitting a roadblock that I donāt know how to overcome with this app inside the Turborepo system.
After much struggling late last week, I did manage to get the Docker image to build without any errors. Running a container from that image technically works, but itās throwing a truckload of errors about files that supposedly canāt be found.
Hereās my Dockerfile, which was tweaked from an example in the Turborepo docs:
# syntax=docker/dockerfile:1
FROM node:latest AS base
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
# WORKDIR /app
COPY --from=installer . .
COPY --from=installer ./app/apps/staff-portal/build/client/ .
RUN npm install -g @react-router/serve@7.6.3
CMD ["react-router-serve", "/app/apps/staff-portal/build/server/index.js"]
When when running a container from the resulting image, the RR server kicks off just fine, but opening the URL in my browser throws a ton of errors that are all a variation on the following:
No routes matched location "/assets/some-file.js"
After figuring out how to navigate the file structure of the image, I found that the assets folder is in /app/apps/staff-portal/build/client. That last COPY instruction is in the file to copy that to the root, thinking that it would solve the problem, but the errors persist.
Iām completely new to Docker (and Turborepo and RR, for that matter), and Iāve only gotten this far with lots of trial and error. At this point Iām out of ideas, and Iām not sure if this is an issue with something that Iāve done re: Docker, or if the root problem lies elsewhere. Any guidance would be greatly appreciated.