From 5d7be15c524530f76b49a0b5416bbebceabc5070 Mon Sep 17 00:00:00 2001 From: Patrik Date: Fri, 21 Feb 2025 13:15:54 -0500 Subject: [PATCH] templates: update docker-compose to use postgres by default in postgres 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 --- templates/with-postgres/docker-compose.yml | 50 ++++++++++--------- .../with-vercel-postgres/docker-compose.yml | 50 ++++++++++--------- .../src/generate-template-variations.ts | 2 + 3 files changed, 56 insertions(+), 46 deletions(-) diff --git a/templates/with-postgres/docker-compose.yml b/templates/with-postgres/docker-compose.yml index 3aba7cc7e2a..40e4acb761e 100644 --- a/templates/with-postgres/docker-compose.yml +++ b/templates/with-postgres/docker-compose.yml @@ -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: diff --git a/templates/with-vercel-postgres/docker-compose.yml b/templates/with-vercel-postgres/docker-compose.yml index 3aba7cc7e2a..40e4acb761e 100644 --- a/templates/with-vercel-postgres/docker-compose.yml +++ b/templates/with-vercel-postgres/docker-compose.yml @@ -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: diff --git a/tools/scripts/src/generate-template-variations.ts b/tools/scripts/src/generate-template-variations.ts index e385edbaec0..c38049a4ab8 100644 --- a/tools/scripts/src/generate-template-variations.ts +++ b/tools/scripts/src/generate-template-variations.ts @@ -68,6 +68,7 @@ async function main() { dbUri: 'POSTGRES_URL', }, sharp: false, + skipDockerCompose: true, storage: 'vercelBlobStorage', vercelDeployButtonLink: `https://vercel.com/new/clone?repository-url=` + @@ -107,6 +108,7 @@ async function main() { db: 'postgres', dirname: 'with-postgres', sharp: true, + skipDockerCompose: true, storage: 'localDisk', }, {