Skip to content

Commit f89e736

Browse files
authored
chore: consolidate docker scripts into single docker-compose with profiles (#15974)
Replaces 18 docker scripts and 4 separate docker-compose files with 3 scripts and 1 unified compose file using Docker Compose profiles. ``` pnpm docker:start # Nuke volumes + start all services fresh pnpm docker:stop # Stop everything pnpm docker:test # Test database connections ``` The goal is one single command that covers 99% of cases: `pnpm docker:start`. Running it gives you all services started clean, with no leftover data from previous runs. No more looking through `package.json` for the right `docker:mongodb:start` or `docker:postgres:restart:clean` - just one command. Docker Compose starts all services in parallel, so there's no performance overhead compared to the old targeted commands. <img width="1284" height="922" alt="screenshot 2026-03-16 at 17 11 44@2x" src="https://github.com/user-attachments/assets/56c35547-5b82-496e-9200-cb43982c0dad" /> All services (PostgreSQL, MongoDB, mongot, MongoDB Atlas Local, LocalStack, Azure Storage, GCS) now show grouped under a single `payload-monorepo` project in Docker Desktop / Orbstack, as seen in the screenshot. All services are defined in `test/docker-compose.yml` with profiles (`postgres`, `mongodb`, `mongodb-atlas`, `storage`, `all`). CI uses individual profiles to start only what it needs.
1 parent 5efc2ff commit f89e736

10 files changed

Lines changed: 161 additions & 227 deletions

File tree

.github/actions/start-database/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ runs:
2525
if: contains(fromJSON('["mongodb", "cosmosdb", "documentdb", "firestore"]'), inputs.database)
2626
shell: bash
2727
run: |
28-
docker compose -f test/__helpers/shared/db/mongodb/docker-compose.yml up -d --wait
28+
docker compose -f test/docker-compose.yml --profile mongodb up -d --wait
2929
echo "url=mongodb://payload:payload@localhost:27018/payload?authSource=admin&directConnection=true&replicaSet=rs0" >> $GITHUB_OUTPUT
3030
3131
- name: Start MongoDB Atlas Local
3232
id: mongodb-atlas
3333
if: inputs.database == 'mongodb-atlas'
3434
shell: bash
3535
run: |
36-
docker compose -f test/__helpers/shared/db/mongodb-atlas/docker-compose.yml up -d --wait
36+
docker compose -f test/docker-compose.yml --profile mongodb-atlas up -d --wait
3737
echo "url=mongodb://localhost:27019/payload?directConnection=true&replicaSet=mongodb-atlas-local" >> $GITHUB_OUTPUT
3838
3939
- name: Start PostgreSQL
4040
id: postgres
4141
if: startsWith(inputs.database, 'postgres')
4242
shell: bash
4343
run: |
44-
docker compose -f test/__helpers/shared/db/postgres/docker-compose.yml up -d --wait
44+
docker compose -f test/docker-compose.yml --profile postgres up -d --wait
4545
echo "url=postgresql://payload:payload@localhost:5433/payload" >> $GITHUB_OUTPUT
4646
4747
- name: Configure PostgreSQL custom schema

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Payload is a monorepo structured around Next.js, containing the core CMS platfor
8282
- Auto-login is enabled by default with credentials: `dev@payloadcms.com` / `test`
8383
- To disable: pass `--no-auto-login` flag or set `PAYLOAD_PUBLIC_DISABLE_AUTO_LOGIN=false`
8484
- Default database is MongoDB (in-memory). Switch to Postgres with `PAYLOAD_DATABASE=postgres`
85-
- Docker services: `pnpm docker:start` / `pnpm docker:stop` / `pnpm docker:restart`
85+
- Docker services: `pnpm docker:start` / `pnpm docker:stop` / `pnpm docker:test`
8686

8787
### Playwright MCP
8888

CONTRIBUTING.md

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -140,43 +140,29 @@ Set `PAYLOAD_DATABASE` in your `.env` file to choose the database adapter:
140140
- `supabase` - Supabase (PostgreSQL)
141141
- `d1` - D1 (SQLite)
142142

143-
Then use Docker to start your database.
143+
Then use Docker to start your databases and storage emulators.
144144

145-
On MacOS, the easiest way to install Docker is to use brew. Simply run `pnpm install --cask docker`, open the docker desktop app, apply the recommended settings and you're good to go.
146-
147-
### PostgreSQL
145+
On MacOS, the easiest way to install Docker is to use brew. Simply run `brew install --cask docker`, open the docker desktop app, apply the recommended settings and you're good to go.
148146

149147
```bash
150-
pnpm docker:postgres:start # Start (persists data)
151-
pnpm docker:postgres:restart:clean # Start fresh (removes data)
152-
pnpm docker:postgres:stop # Stop
148+
pnpm docker:start # Start all services (PostgreSQL, MongoDB, storage emulators) with fresh data
149+
pnpm docker:stop # Stop all services
150+
pnpm docker:test # Test database connections
153151
```
154152

155-
URL: `postgres://payload:payload@127.0.0.1:5433/payload`
156-
157-
### MongoDB (with vector search)
158-
159-
```bash
160-
pnpm docker:mongodb:start # Start (persists data)
161-
pnpm docker:mongodb:restart:clean # Start fresh (removes data)
162-
pnpm docker:mongodb:stop # Stop
163-
```
153+
Every `docker:start` automatically removes old data and starts fresh, so you always get a clean environment.
164154

165-
URL: `mongodb://payload:payload@localhost:27018/payload?authSource=admin&directConnection=true&replicaSet=rs0`
166-
167-
### MongoDB Atlas Local
168-
169-
```bash
170-
pnpm docker:mongodb-atlas:start # Start (persists data)
171-
pnpm docker:mongodb-atlas:restart:clean # Start fresh (removes data)
172-
pnpm docker:mongodb-atlas:stop # Stop
173-
```
155+
All services are defined in a single `test/docker-compose.yml` using Docker Compose profiles (`postgres`, `mongodb`, `mongodb-atlas`, `storage`, `all`).
174156

175-
URL: `mongodb://localhost:27019/payload?directConnection=true&replicaSet=mongodb-atlas-local` (no auth required)
157+
**Connection URLs:**
176158

177-
### SQLite
159+
| Database | URL |
160+
| ------------------- | --------------------------------------------------------------------------------------------------------- |
161+
| PostgreSQL | `postgres://payload:payload@127.0.0.1:5433/payload` |
162+
| MongoDB | `mongodb://payload:payload@localhost:27018/payload?authSource=admin&directConnection=true&replicaSet=rs0` |
163+
| MongoDB Atlas Local | `mongodb://localhost:27019/payload?directConnection=true&replicaSet=mongodb-atlas-local` (no auth) |
178164

179-
SQLite databases don't require Docker - they're stored as files in the project.
165+
SQLite databases don't require Docker they're stored as files in the project.
180166

181167
### Testing with your own database
182168

package.json

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,9 @@
8282
"dev:prod": "cross-env NODE_OPTIONS=--no-deprecation tsx ./test/dev.ts --prod",
8383
"dev:vercel-postgres": "cross-env PAYLOAD_DATABASE=vercel-postgres pnpm runts ./test/dev.ts",
8484
"devsafe": "node ./scripts/delete-recursively.js '**/.next' && pnpm dev",
85-
"docker:mongodb-atlas:restart": "pnpm docker:mongodb-atlas:stop && pnpm docker:mongodb-atlas:start",
86-
"docker:mongodb-atlas:restart:clean": "docker rm -f mongodb-atlas-payload-test 2>/dev/null; docker compose -f test/__helpers/shared/db/mongodb-atlas/docker-compose.yml down -v && pnpm docker:mongodb-atlas:start",
87-
"docker:mongodb-atlas:start": "docker compose -f test/__helpers/shared/db/mongodb-atlas/docker-compose.yml up -d --wait",
88-
"docker:mongodb-atlas:stop": "docker compose -f test/__helpers/shared/db/mongodb-atlas/docker-compose.yml down",
89-
"docker:mongodb-atlas:test": "pnpm runts test/__helpers/shared/db/mongodb-atlas/run-test-connection.ts",
90-
"docker:mongodb:restart": "pnpm docker:mongodb:stop && pnpm docker:mongodb:start",
91-
"docker:mongodb:restart:clean": "docker rm -f mongodb-payload-test mongot-payload-test 2>/dev/null; docker compose -f test/__helpers/shared/db/mongodb/docker-compose.yml down -v && pnpm docker:mongodb:start",
92-
"docker:mongodb:start": "docker compose -f test/__helpers/shared/db/mongodb/docker-compose.yml up -d --wait",
93-
"docker:mongodb:stop": "docker rm -f mongodb-payload-test mongot-payload-test 2>/dev/null; docker compose -f test/__helpers/shared/db/mongodb/docker-compose.yml down",
94-
"docker:mongodb:test": "pnpm runts test/__helpers/shared/db/mongodb/run-test-connection.ts",
95-
"docker:postgres:restart": "pnpm docker:postgres:stop && pnpm docker:postgres:start",
96-
"docker:postgres:restart:clean": "docker rm -f postgres-payload-test 2>/dev/null; docker compose -f test/__helpers/shared/db/postgres/docker-compose.yml down -v && pnpm docker:postgres:start",
97-
"docker:postgres:start": "docker compose -f test/__helpers/shared/db/postgres/docker-compose.yml up -d --wait",
98-
"docker:postgres:start:clean": "docker pull ghcr.io/payloadcms/postgis-vector:latest && docker compose -f test/__helpers/shared/db/postgres/docker-compose.yml down -v && docker compose -f test/__helpers/shared/db/postgres/docker-compose.yml up -d --wait",
99-
"docker:postgres:stop": "docker rm -f postgres-payload-test 2>/dev/null; docker compose -f test/__helpers/shared/db/postgres/docker-compose.yml down",
100-
"docker:restart": "pnpm docker:stop --remove-orphans && pnpm docker:start",
101-
"docker:start": "docker compose -f test/docker-compose.yml up -d",
102-
"docker:stop": "docker compose -f test/docker-compose.yml down",
85+
"docker:start": "docker compose -f test/docker-compose.yml --profile all down -v --remove-orphans 2>/dev/null; docker compose -f test/docker-compose.yml --profile all up -d --wait",
86+
"docker:stop": "docker compose -f test/docker-compose.yml --profile all down --remove-orphans",
87+
"docker:test": "pnpm runts test/__helpers/shared/db/mongodb/run-test-connection.ts && pnpm runts test/__helpers/shared/db/mongodb-atlas/run-test-connection.ts",
10388
"force:build": "pnpm run build:core:force",
10489
"lint": "turbo run lint --log-order=grouped --continue --filter \"!blank\" --filter \"!website\" --filter \"!ecommerce\"",
10590
"lint-staged": "lint-staged",

packages/storage-s3/docker-compose.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

test/__helpers/shared/db/mongodb-atlas/docker-compose.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

test/__helpers/shared/db/mongodb/docker-compose.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

test/__helpers/shared/db/postgres/docker-compose.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)