From 4bfa329fa4b8aa628f568d5767365e5226ad3848 Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Tue, 17 Dec 2024 15:17:18 -0500 Subject: [PATCH] templates: document local development (#10032) Provide docker-compose for spinning up postgres locally along w/ relevant info in README. --- scripts/generate-template-variations.ts | 1 + templates/with-vercel-website/README.md | 19 +- .../with-vercel-website/docker-compose.yml | 32 +--- .../with-vercel-website/src/payload-types.ts | 163 ++++++++---------- 4 files changed, 97 insertions(+), 118 deletions(-) diff --git a/scripts/generate-template-variations.ts b/scripts/generate-template-variations.ts index 045bbb0550b..8b6d1793ee7 100644 --- a/scripts/generate-template-variations.ts +++ b/scripts/generate-template-variations.ts @@ -104,6 +104,7 @@ async function main() { dbUri: 'POSTGRES_URL', }, skipReadme: true, + skipDockerCompose: true, }, { name: 'payload-postgres-template', diff --git a/templates/with-vercel-website/README.md b/templates/with-vercel-website/README.md index d8fbd3d3aeb..d9957d678ed 100644 --- a/templates/with-vercel-website/README.md +++ b/templates/with-vercel-website/README.md @@ -35,14 +35,25 @@ After you click the `Deploy` button above, you'll want to have standalone copy o ### Development 1. First [clone the repo](#clone) if you have not done so already -1. `cd my-project && cp .env.example .env` to copy the example environment variables. You'll need to add the `POSTGRES_URL` and `BLOB_READ_WRITE_TOKEN` from your Vercel project to your `.env` if you want to use Vercel Blob and the Neon database that was created for you. -1. `pnpm install && pnpm dev` to install dependencies and start the dev server -1. open `http://localhost:3000` to open the app in your browser +2. `cd my-project && cp .env.example .env` to copy the example environment variables. You'll need to add the `POSTGRES_URL` and `BLOB_READ_WRITE_TOKEN` from your Vercel project to your `.env` if you want to use Vercel Blob and the Neon database that was created for you. -You might + > _NOTE: If the connection string value includes `localhost` or `127.0.0.1`, the code will automatically use a normal postgres adapter instead of Vercel._. You can override this functionality by setting `forceUseVercelPostgres: true` if desired. + +3. `pnpm install && pnpm dev` to install dependencies and start the dev server +4. open `http://localhost:3000` to open the app in your browser That's it! Changes made in `./src` will be reflected in your app. Follow the on-screen instructions to login and create your first admin user. Then check out [Production](#production) once you're ready to build and serve your app, and [Deployment](#deployment) when you're ready to go live. +#### Docker (Optional) + +If you prefer to use Docker for local development instead of a local Postgres instance, the provided docker-compose.yml file can be used. + +To do so, follow these steps: + +- Modify the `POSTGRES_URL` in your `.env` file to `postgres://postgres@postgres:54320/` +- Modify the `docker-compose.yml` file's `POSTGRES_DB` to match the above `` +- Run `docker-compose up` to start the database, optionally pass `-d` to run in the background. + ## How it works The Payload config is tailored specifically to the needs of most websites. It is pre-configured in the following ways: diff --git a/templates/with-vercel-website/docker-compose.yml b/templates/with-vercel-website/docker-compose.yml index 4c9fc519402..eac27ce09d2 100644 --- a/templates/with-vercel-website/docker-compose.yml +++ b/templates/with-vercel-website/docker-compose.yml @@ -1,31 +1,13 @@ version: '3' services: - payload: - image: node:18-alpine + postgres: + image: postgres ports: - - '3000:3000' - volumes: - - .:/home/node/app - - node_modules:/home/node/app/node_modules - working_dir: /home/node/app/ - command: sh -c "yarn install && yarn dev" - depends_on: - - mongo + - '54320:5432' + environment: + POSTGRES_USER: postgres + POSTGRES_DB: payloadtests # THIS MUST MATCH YOUR DB NAME IN .env + POSTGRES_HOST_AUTH_METHOD: trust env_file: - .env - - mongo: - image: mongo:latest - ports: - - '27017:27017' - command: - - --storageEngine=wiredTiger - volumes: - - data:/data/db - logging: - driver: none - -volumes: - data: - node_modules: diff --git a/templates/with-vercel-website/src/payload-types.ts b/templates/with-vercel-website/src/payload-types.ts index c273ffd4b5c..7771180d495 100644 --- a/templates/with-vercel-website/src/payload-types.ts +++ b/templates/with-vercel-website/src/payload-types.ts @@ -805,11 +805,80 @@ export interface PagesSelect { layout?: | T | { - cta?: T | CallToActionBlockSelect; - content?: T | ContentBlockSelect; - mediaBlock?: T | MediaBlockSelect; - archive?: T | ArchiveBlockSelect; - formBlock?: T | FormBlockSelect; + cta?: + | T + | { + richText?: T; + links?: + | T + | { + link?: + | T + | { + type?: T; + newTab?: T; + reference?: T; + url?: T; + label?: T; + appearance?: T; + }; + id?: T; + }; + id?: T; + blockName?: T; + }; + content?: + | T + | { + columns?: + | T + | { + size?: T; + richText?: T; + enableLink?: T; + link?: + | T + | { + type?: T; + newTab?: T; + reference?: T; + url?: T; + label?: T; + appearance?: T; + }; + id?: T; + }; + id?: T; + blockName?: T; + }; + mediaBlock?: + | T + | { + media?: T; + id?: T; + blockName?: T; + }; + archive?: + | T + | { + introContent?: T; + populateBy?: T; + relationTo?: T; + categories?: T; + limit?: T; + selectedDocs?: T; + id?: T; + blockName?: T; + }; + formBlock?: + | T + | { + form?: T; + enableIntro?: T; + introContent?: T; + id?: T; + blockName?: T; + }; }; meta?: | T @@ -825,90 +894,6 @@ export interface PagesSelect { createdAt?: T; _status?: T; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "CallToActionBlock_select". - */ -export interface CallToActionBlockSelect { - richText?: T; - links?: - | T - | { - link?: - | T - | { - type?: T; - newTab?: T; - reference?: T; - url?: T; - label?: T; - appearance?: T; - }; - id?: T; - }; - id?: T; - blockName?: T; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "ContentBlock_select". - */ -export interface ContentBlockSelect { - columns?: - | T - | { - size?: T; - richText?: T; - enableLink?: T; - link?: - | T - | { - type?: T; - newTab?: T; - reference?: T; - url?: T; - label?: T; - appearance?: T; - }; - id?: T; - }; - id?: T; - blockName?: T; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "MediaBlock_select". - */ -export interface MediaBlockSelect { - media?: T; - id?: T; - blockName?: T; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "ArchiveBlock_select". - */ -export interface ArchiveBlockSelect { - introContent?: T; - populateBy?: T; - relationTo?: T; - categories?: T; - limit?: T; - selectedDocs?: T; - id?: T; - blockName?: T; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "FormBlock_select". - */ -export interface FormBlockSelect { - form?: T; - enableIntro?: T; - introContent?: T; - id?: T; - blockName?: T; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "posts_select".