Remix Blues/Stack OOM and no seeding

I have been trying for about 5 days to deploy a simple Remix Blues Stack starter to Fly.io. It consistently OOMs (even on the paid tier). There also is no documentation for how to run the seed command as part of the deploy or manually after the deploy. Attempts lead to more OOMs or missing deps (that are in node_modules when I ls). A few times it has deployed without OOM but then later with no changes it OOMs during npx prisma migrate deploy. Even when it succeeds, the seed command is not run so all of the tables are empty. Any ideas would be greatly appreciated, this has been the most frustrating dev experience I have had in years.

Regarding the OOM issue, you can change your machine’s memory size by fly scale command;

% fly scale memory 1024
Updating machine 6e82d5d4b0e387
No health checks found
Machine 6e82d5d4b0e387 updated successfully!
Scaled VM Type to 'shared-cpu-2x'
      CPU Cores: 2
         Memory: 1024 MB
%

Regarding running commands in your machine, fly ssh console is the way to ssh into the machine.

Thanks, did you already run it? I guess I don’t understand why I need 1GB of memory for a starter project.

I have tried ssh’ing in and running the seed command but it fails because of memory or missing dependencies.

No. I didn’t run the command against your machines.

You can check your machine size by fly scale show and then change the memory size incrementally by fly scale memory.

Thanks, I will try that.

Okay, that gets the initial deploy working again. But I still can’t run the seed command while ssh because it seems to be missing dependencies even though they are in node_modules when I ls. I made two copies of the seed script (JS and TS). Running the JS version I get that bcryptjs is undefined even though it is in node_modules and package.json dependencies. I am also trying npx prisma db seed and it fails because I think it is missing ts-node, but even installing that it fails to find it. Any ideas?

Glad that at least the deployment issue was resolved!

Regarding the seed issue, what was the whole error you got?

It’s really for any node usage inside ssh. It tells me that dependencies aren’t installed. For example, I may try to run ts-node prisma/seed.ts from the /myapp directory but it says ts-node is not found. I then npm install ts-node and run it again, but the same error. If I use npx ts-node prisma/seed.ts it lets me install ts-node, but then fails on the next missing dependency. All of these are installed and in the node_modules directory, so not sure why it’s not finding them.

Do you have ts-node in dependencies or devDependencies?

Can you show us your whole Dockerfile and package.json?

I did check and see ts-node and typescript are devDependecies, which I think is why fly can’t find them (even though they are in node_modules?). But that doesn’t explain why when trying to run the compiled JS version of the script that it’s dependencies are missing. For example, the script requires bcryptjs which is a dependency and is also in node_modules, but running node prisma/seed.js it is claimed to be uninstalled.

Without seeing your Dockerfile or .dockerignore, I’m only guessing here but node_modules is typically in your dockerignore so it isn’t uploaded and then your dockerfile typically only installs production dependencies.

Hm, okay, but I do see node_modules when I ssh in to myapp dir. Is that the wrong directory? I think I have something that may work by changing the TS config and compiling the JS file ahead of time. The seed script is running now in the myapp dir. Waiting to see if it work.

No, the script stopped with no console messages or in the Fly monitoring UI. Here is the Dockerfile. I am just trying to seed my DB :sweat_smile:

base node image

FROM node:16-bullseye-slim as base

set for base and all layer that inherit from it

ENV NODE_ENV production

Install openssl for Prisma

RUN apt-get update && apt-get install -y openssl

Install all node_modules, including dev dependencies

FROM base as deps

WORKDIR /myapp

ADD package.json package-lock.json .npmrc ./
RUN npm install --production=false

Setup production node_modules

FROM base as production-deps

WORKDIR /myapp

COPY --from=deps /myapp/node_modules /myapp/node_modules
ADD package.json package-lock.json .npmrc ./
RUN npm prune --production

Build the app

FROM base as build

WORKDIR /myapp

COPY --from=deps /myapp/node_modules /myapp/node_modules

ADD prisma .
RUN npx prisma generate

ADD . .
RUN npm run build

Finally, build the production image with minimal footprint

FROM base

WORKDIR /myapp

COPY --from=production-deps /myapp/node_modules /myapp/node_modules
COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma

COPY --from=build /myapp/build /myapp/build
COPY --from=build /myapp/public /myapp/public
ADD . .

CMD [“npm”, “start”]

Oh! Actually it did seem to do some seeding, but didn’t log out the usual logs in the seed script. Can’t tell if it did everything. I think that will work for now! Would love for some more documentation on this with Remix. I’ve found several Github/Discord/Fly forum posts with the same issues and little info.