remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
29.81k stars 2.51k forks source link

2 Jokes tutorial bugs: (RSS doesn't work) + (Fly's .dockerignore doesn't work for Prisma) #2108

Closed cweekly closed 1 year ago

cweekly commented 2 years ago

What version of Remix are you using?

1.1.3

Steps to Reproduce

Disclaimer: I'm still genuinely excited about Remix, but in stepping through the remix-jokes tutorial I ran into a couple acute issues that left me scratching my head. I feel pretty confident others must have encountered them too. Hoping that posting here might help shed some light.

Issue 1: Resource Routes / RSS feature:

The tutorial's implementation differs from this repo's, and AFAICT neither of them work. https://remix-jokes.lol/jokes.rss (like my follow-along-at-home version) returns a 200 response but there are no joke s, just the feed metadata ending with . I stopped trying to debug it when I realized it wasn't just me.

Issue 2: Deployment: Prisma vs Fly.io's default .dockerignore:

The .dockerignore file noted in the tutorial and present in this repo, auto-generated by fly launch, consists of just one path to ignore: node_modules. That's pretty standard and seems reasonable. BUT. Prisma is weird, in that it relies on generating files in node_modules/prisma -- which files are not present following npm install! (This gives me the heebie-jeebies, even tho the Prisma APIs are really nice.) So in following the tutorial step-by-step, the fly deploy step fails with errors like:

Error: Cannot find module '/root/.npm/_npx/524/lib/node_modules/prisma/scripts/preinstall-entry.js'

The only way I could mitigate this problem was to edit the .dockerignore file, adding an exclusion to NOT ignore node_modules/prisma in particular:

!node_modules/prisma

... which fixed the problem.

But, how did the setup in this repo and/or noted in the tutorial's prose ever work without making this change? Thanks in advance for any responses!

Expected Behavior

Issue 1: Resource Routes / RSS feature:

I expected the feature to be demonstrated, with the list of jokes properly rendered in the RSS feed.

Issue 2: .dockerignore for Prisma on Fly.io:

I expected the steps in the tutorial prose (and the corresponding .dockerignore file in the repo) to lead to successful fly.io deployments, and not to require research and debugging and a very different-looking .dockerignore file.

Actual Behavior

See "Steps to reproduce above".

cweekly commented 2 years ago

Note I recreated this bug based on @kentcdodds's comment in the now-archived original repo: https://github.com/remix-run/remix-jokes/issues/18#issuecomment-1043549314

Also, it looks like the RSS issue has evolved since last week. Previously, the list of jokes was missing from the RSS output. Now, it seems the jokes are rendered, but they currently blow up on an XML parsing error (an unescaped ampersand char).

cweekly commented 2 years ago

Summary / suggestions:

Issue 1: RSS - the main issue seems to be fixed in the latest iteration of the code deployed to https://remix-jokes.lol.jokes.rss. Fixing the HTML character entity / escaping issue would be helpful.

Issue 2: Prisma / .dockerignore for Fly.io deployment - I'm not blocked here, but having figured out why the tutorial steps didn't work I'd really like to save others the hassle, e.g. via an update to the tutorial prose acknowledging that the fly-generated .dockerignore file won't work with Prisma.

HTH, Chris

kentcdodds commented 2 years ago

Thanks for reporting these issues! I'll add this to my list and get these issues fixed!

philip-weber commented 2 years ago

@cweekly, I do not think adding !node_modules/prisma to .dockerignore is the right way. As far as I can see this only works for deployments from your machine but not if you were deployment through CI because in that case the Prisma files would not be generated. Please have a look at the Dockerfile generated from fly.io when using fly launch.

Dockerfile line 36-38

# If we're using Prisma, uncomment to cache the prisma schema
# ADD prisma .
# RUN npx prisma generate

Dockerfile line 53-54

# Uncomment if using Prisma
# COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma

You would want to uncomment line 37-38 and 54. This way all needed Prisma files are generated and copied as a build step within the deployment.

Nevertheless, it would be good to point that out in the tutorial.

kentcdodds commented 2 years ago

I'm going to be making some significant edits to both tutorials this week to take advantage of a new feature we're shipping. Please standby.

cweekly commented 2 years ago

@philip-weber - Thanks. I understand exactly what you're saying. I think there are unresolved inconsistencies / conflicts, between these 2 scenarios: A) "build and deploy from local/laptop" (as described in the tutorial, where prisma generate is run manually) VS
B) "build and deploy from CI" (as you mentioned).

But I don't have time to try to prove it, and per Kent's comment, it may soon all be moot anyway. Good luck w/ all the other things you're working on for Remix! :)

machour commented 1 year ago

Closing as the tutorial was revamped by Kent a while ago. Please open a new issue if you're still seeing problems with the jokes tutorial.