Skip to content

Commit

Permalink
templates: update docker-compose to use postgres by default in postgr…
Browse files Browse the repository at this point in the history
…es specific templates (#11328)

### What?

Updated `docker-compose.yml` to use `Postgres` by default, with
`MongoDB` commented out in the templates that are by default using the
postgres adapter.

Fixes #11322
  • Loading branch information
PatrikKozak authored Feb 21, 2025
1 parent 0058f82 commit 5d7be15
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 46 deletions.
50 changes: 27 additions & 23 deletions templates/with-postgres/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,46 @@ version: '3'

services:
payload:
image: node:18-alpine
image: node:20-alpine
ports:
- '3000:3000'
volumes:
- .:/home/node/app
- node_modules:/home/node/app/node_modules
working_dir: /home/node/app/
command: sh -c "corepack enable && corepack prepare pnpm@latest --activate && pnpm install && pnpm dev"
command: sh -c "corepack enable && corepack prepare pnpm@9.0.0 --activate && pnpm install && pnpm dev"
depends_on:
- mongo
# - postgres
- postgres
# - mongo
env_file:
- .env

# Ensure your DATABASE_URI uses 'mongo' as the hostname ie. mongodb://mongo/my-db-name
mongo:
image: mongo:latest
ports:
- '27017:27017'
command:
- --storageEngine=wiredTiger
# Ensure your DATABASE_URI uses 'postgresql' as the hostname ie. postgresql://127.0.0.1:5432/your-database-name
postgres:
restart: always
image: postgres:latest
volumes:
- data:/data/db
logging:
driver: none
- pgdata:/var/lib/postgresql/data
ports:
- '5432:5432'
environment:
POSTGRES_USER: postgres
POSTGRES_DB: your-database-name # THIS MUST MATCH YOUR DB NAME IN .env
POSTGRES_HOST_AUTH_METHOD: trust

# Uncomment the following to use postgres
# postgres:
# restart: always
# image: postgres:latest
# volumes:
# - pgdata:/var/lib/postgresql/data
# Uncomment the following to use mongodb
# mongo:
# image: mongo:latest
# ports:
# - "5432:5432"
# - '27017:27017'
# command:
# - --storageEngine=wiredTiger
# volumes:
# - data:/data/db
# logging:
# driver: none

volumes:
data:
# pgdata:
pgdata:
# data:
node_modules:
50 changes: 27 additions & 23 deletions templates/with-vercel-postgres/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,46 @@ version: '3'

services:
payload:
image: node:18-alpine
image: node:20-alpine
ports:
- '3000:3000'
volumes:
- .:/home/node/app
- node_modules:/home/node/app/node_modules
working_dir: /home/node/app/
command: sh -c "corepack enable && corepack prepare pnpm@latest --activate && pnpm install && pnpm dev"
command: sh -c "corepack enable && corepack prepare pnpm@9.0.0 --activate && pnpm install && pnpm dev"
depends_on:
- mongo
# - postgres
- postgres
# - mongo
env_file:
- .env

# Ensure your DATABASE_URI uses 'mongo' as the hostname ie. mongodb://mongo/my-db-name
mongo:
image: mongo:latest
ports:
- '27017:27017'
command:
- --storageEngine=wiredTiger
# Ensure your DATABASE_URI uses 'postgresql' as the hostname ie. postgresql://127.0.0.1:5432/your-database-name
postgres:
restart: always
image: postgres:latest
volumes:
- data:/data/db
logging:
driver: none
- pgdata:/var/lib/postgresql/data
ports:
- '5432:5432'
environment:
POSTGRES_USER: postgres
POSTGRES_DB: your-database-name # THIS MUST MATCH YOUR DB NAME IN .env
POSTGRES_HOST_AUTH_METHOD: trust

# Uncomment the following to use postgres
# postgres:
# restart: always
# image: postgres:latest
# volumes:
# - pgdata:/var/lib/postgresql/data
# Uncomment the following to use mongodb
# mongo:
# image: mongo:latest
# ports:
# - "5432:5432"
# - '27017:27017'
# command:
# - --storageEngine=wiredTiger
# volumes:
# - data:/data/db
# logging:
# driver: none

volumes:
data:
# pgdata:
pgdata:
# data:
node_modules:
2 changes: 2 additions & 0 deletions tools/scripts/src/generate-template-variations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ async function main() {
dbUri: 'POSTGRES_URL',
},
sharp: false,
skipDockerCompose: true,
storage: 'vercelBlobStorage',
vercelDeployButtonLink:
`https://vercel.com/new/clone?repository-url=` +
Expand Down Expand Up @@ -107,6 +108,7 @@ async function main() {
db: 'postgres',
dirname: 'with-postgres',
sharp: true,
skipDockerCompose: true,
storage: 'localDisk',
},
{
Expand Down

0 comments on commit 5d7be15

Please sign in to comment.