Skip to content

Commit

Permalink
templates: document local development (#10032)
Browse files Browse the repository at this point in the history
Provide docker-compose for spinning up postgres locally along w/
relevant info in README.
  • Loading branch information
denolfe authored Dec 17, 2024
1 parent f5c13de commit 4bfa329
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 118 deletions.
1 change: 1 addition & 0 deletions scripts/generate-template-variations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ async function main() {
dbUri: 'POSTGRES_URL',
},
skipReadme: true,
skipDockerCompose: true,
},
{
name: 'payload-postgres-template',
Expand Down
19 changes: 15 additions & 4 deletions templates/with-vercel-website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<dbname>`
- Modify the `docker-compose.yml` file's `POSTGRES_DB` to match the above `<dbname>`
- 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:
Expand Down
32 changes: 7 additions & 25 deletions templates/with-vercel-website/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
163 changes: 74 additions & 89 deletions templates/with-vercel-website/src/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,11 +805,80 @@ export interface PagesSelect<T extends boolean = true> {
layout?:
| T
| {
cta?: T | CallToActionBlockSelect<T>;
content?: T | ContentBlockSelect<T>;
mediaBlock?: T | MediaBlockSelect<T>;
archive?: T | ArchiveBlockSelect<T>;
formBlock?: T | FormBlockSelect<T>;
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
Expand All @@ -825,90 +894,6 @@ export interface PagesSelect<T extends boolean = true> {
createdAt?: T;
_status?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "CallToActionBlock_select".
*/
export interface CallToActionBlockSelect<T extends boolean = true> {
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<T extends boolean = true> {
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<T extends boolean = true> {
media?: T;
id?: T;
blockName?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "ArchiveBlock_select".
*/
export interface ArchiveBlockSelect<T extends boolean = true> {
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<T extends boolean = true> {
form?: T;
enableIntro?: T;
introContent?: T;
id?: T;
blockName?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "posts_select".
Expand Down

0 comments on commit 4bfa329

Please sign in to comment.