From f8a6fc9e0d6322d7d4487a2ece17c740054f7a8a Mon Sep 17 00:00:00 2001 From: Lily Mara Date: Fri, 27 Oct 2023 08:44:26 -0700 Subject: [PATCH 1/3] Improve developer environment onboarding I encountered a number of issues while trying to get my own local dev environment set up. This change adds missing information to the readme, updates the Postgres image to one that includes required module dependencies, and removes next.js rewrite rules (IS THIS SAFE?) which were no longer used and causing issues. --- README.md | 17 ++++++++++++++--- docker-compose.yml | 2 +- packages/web/next.config.js | 22 ---------------------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 111cdb065..eb30a36ad 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/omnivore-app/omnivore/Run%20tests)](https://github.com/omnivore-app/omnivore/actions/workflows/run-tests.yaml) [![Discord](https://img.shields.io/discord/844965259462311966?label=Join%20our%20Discord)](https://discord.gg/h2z5rppzz9) -[![Mastodon Follow](https://img.shields.io/mastodon/follow/109458738600914558?domain=https%3A%2F%2Fpkm.social)](https://pkm.social/@omnivore) +[![Mastodon Follow](https://img.shields.io/mastodon/follow/109458738600914558?domain=https%3A%2F%2Fpkm.social)](https://pkm.social/@omnivore) [![Twitter Follow](https://img.shields.io/twitter/follow/omnivoreapp)](https://twitter.com/OmnivoreApp) ![GitHub](https://img.shields.io/github/license/omnivore-app/omnivore) @@ -34,7 +34,6 @@ We also have a free hosted version of Omnivore at [omnivore.app](https://omnivor web-screenshot-listview - ## Join us on Discord! :speech_balloon: We're building our community on Discord. [Join us!](https://discord.gg/h2z5rppzz9) @@ -100,10 +99,22 @@ with docker compose and the frontend locally: ```bash docker compose up api content-fetch cd packages/web -cp .env.template .env +cp .env.template .env.local yarn dev ``` +You will need to configure some values in the new `.env.local` file. These are +the values for running the `web` service directly on your host machine and +running `api` and `content-fetch` within docker: + +```sh +NEXT_PUBLIC_BASE_URL=http://localhost:3000 +NEXT_PUBLIC_HIGHLIGHTS_BASE_URL=http://localhost:3000 +NEXT_PUBLIC_LOCAL_BASE_URL=http://localhost:3000 +NEXT_PUBLIC_SERVER_BASE_URL=http://localhost:4000 +NEXT_PUBLIC_LOCAL_SERVER_BASE_URL=http://localhost:4000 +``` + ### Running the puppeteer-parse service outside of Docker To save pages you need to run the `puppeteer-parse` service. diff --git a/docker-compose.yml b/docker-compose.yml index a4f8bcda6..0c5db1e06 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: postgres: - image: "postgres:12.8" + image: "ankane/pgvector:v0.5.1" container_name: "omnivore-postgres" environment: - POSTGRES_USER=postgres diff --git a/packages/web/next.config.js b/packages/web/next.config.js index 6e5012480..aa282657b 100644 --- a/packages/web/next.config.js +++ b/packages/web/next.config.js @@ -24,28 +24,6 @@ const moduleExports = { 'proxy.omnivore-image-cache.app', ], }, - rewrites: () => [ - { - source: '/api/graphql', - destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/graphql`, - }, - { - source: '/api/auth/:path*', - destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/auth/:path*`, - }, - { - source: '/api/article/save', - destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/article/save`, - }, - { - source: '/api/mobile-auth/:path*', - destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/mobile-auth/:path*`, - }, - { - source: '/collect/:match*', - destination: 'https://app.posthog.com/:match*', - }, - ], async headers() { return [ { From 67766eefbb1b3727c96afe1287ced16eb12b550b Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 3 Nov 2023 15:23:21 +0800 Subject: [PATCH 2/3] Add an environment variable for the legacy rewrite rules that arent needed for local dev --- packages/web/next.config.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/web/next.config.js b/packages/web/next.config.js index aa282657b..21ed643fa 100644 --- a/packages/web/next.config.js +++ b/packages/web/next.config.js @@ -24,6 +24,33 @@ const moduleExports = { 'proxy.omnivore-image-cache.app', ], }, + rewrites: () => + (process.env.INCLUDE_LEGACY_REWRITES + ? [ + { + source: '/api/graphql', + destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/graphql`, + }, + { + source: '/api/auth/:path*', + destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/auth/:path*`, + }, + { + source: '/api/article/save', + destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/article/save`, + }, + { + source: '/api/mobile-auth/:path*', + destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/mobile-auth/:path*`, + }, + ] + : []) + + [ + { + source: '/collect/:match*', + destination: 'https://app.posthog.com/:match*', + }, + ], async headers() { return [ { From 556fa60fc94b8a8e63c2168352620de1c0970bfa Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 3 Nov 2023 15:41:45 +0800 Subject: [PATCH 3/3] Add an environment variable to conditionally use legacy rewrites These rewrites are not needed in dev, but in demo/production we should keep them for some older clients still. --- packages/web/next.config.js | 55 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/packages/web/next.config.js b/packages/web/next.config.js index 21ed643fa..f306d08ef 100644 --- a/packages/web/next.config.js +++ b/packages/web/next.config.js @@ -24,33 +24,34 @@ const moduleExports = { 'proxy.omnivore-image-cache.app', ], }, - rewrites: () => - (process.env.INCLUDE_LEGACY_REWRITES - ? [ - { - source: '/api/graphql', - destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/graphql`, - }, - { - source: '/api/auth/:path*', - destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/auth/:path*`, - }, - { - source: '/api/article/save', - destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/article/save`, - }, - { - source: '/api/mobile-auth/:path*', - destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/mobile-auth/:path*`, - }, - ] - : []) + - [ - { - source: '/collect/:match*', - destination: 'https://app.posthog.com/:match*', - }, - ], + rewrites: () => { + const rewrites = [] + if (process.env.INCLUDE_LEGACY_REWRITES) { + rewrites.push( + { + source: '/api/graphql', + destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/graphql`, + }, + { + source: '/api/auth/:path*', + destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/auth/:path*`, + }, + { + source: '/api/article/save', + destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/article/save`, + }, + { + source: '/api/mobile-auth/:path*', + destination: `https://api-${process.env.NEXT_PUBLIC_APP_ENV}.omnivore.app/api/mobile-auth/:path*`, + } + ) + } + rewrites.push({ + source: '/collect/:match*', + destination: 'https://app.posthog.com/:match*', + }) + return rewrites + }, async headers() { return [ {