Skip to content

nguyenmp/recipes-app

Repository files navigation

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First install dependencies

npm install -g pnpm
pnpm i # pnpm specifically supports our patching system (pnpm patch)

Then set up local env file for PostgreSQL and Cloudflare R2 (AWS S3 compatible blob storage).

# Install the vercel CLI
pnpm i -g vercel

# Link to the project (needs auth and permissions)
vercel link

# Download the environment variables necessary
vercel env pull .env.local

Then, run the development server:

pnpm dev

Visit http://localhost:3000/admin and hit "Reset Database" to seed the database with placeholder data.

Open http://localhost:3000 with your browser to see the result.

Running in docker

docker build --platform=linux/amd64 -t recipes-app-docker .
docker run -it -p 3000:3000 --platform=linux/amd64 -v ./.env.local.docker:/app/.env.local:ro recipes-app-docker

Relies on other services (like postgres) already up from vps-management. That folder has the docker-compose file.

Running Tests

I'm just following the guide at https://nextjs.org/docs/app/building-your-application/testing

We use playwright for end-to-end tests.

pnpm run dev
pnpm exec playwright test [--ui]

It's very noticable that tests can get weird sometimes so clean installing helps a lot:

rm -r .next/cache node_modules
pnpm install
pnpm dev

You can also run tests against production by changing playwright.config.ts to say:

-    baseURL: 'http://localhost:3000',
+    baseURL: 'https://recipes-app-lyart.vercel.app/',

Updating Dependencies

Try updating all dependencies first:

# This ignores package range restrictions and installs latest of everything
pnpm update --latest

You'll likely encounter some errors like eslint being mismatched. As of right now, eslint is released to 9.8.0 but nextjs only supports 8.x. Fix any errors like that manually and rerun with:

# This respects package range restrictions
pnpm update

Make sure to restart the development server, things get weird when you update dependencies while the server is running

rm -r .next/cache && pnpm dev

Importing data and updating placeholder-data.ts

See scripts/process.py.

Resetting production database

We can't hit the reset button on production easily because we have 6 seconds per request (based on lambdas).

I want to self-host but I can't seem to get onnxruntime-node to work on docker.

So temporary workaround is to run local development reset against production database:

vercel env pull --environment=production .env.local
pnpm build && pnpm start
http://localhost:3000/admin
Hit reset
vercel env pull .env.local

Test cases I like

white rice - my personal recipes should be on top instantpot rice rice

Running migrations

set -a && source .env.local && set +a
pnpm migrate

or via docker, see vps-management

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published