fix(setup): resolve first-run friction for new clones#56
Merged
Conversation
Previously, running setup in a fresh clone or second worktree crashed with a Docker name conflict because oricms-postgres was already in use. Now the script checks for an existing container and reuses it if running, or removes it before starting fresh. Also detects whether docker compose (v2 plugin) or docker-compose (legacy) is available and uses the right command.
Both .env.example files now share consistent DATABASE_URL credentials (postgresql://oricms:oricms@localhost:5432/oricms) so a first-time user can connect to the Docker Postgres without editing the file. JWT_SECRET and ENCRYPTION_KEY use clearly fake placeholder strings (REPLACE_ME...) instead of values that look like they might be real. This makes it obvious when someone has forgotten to set them. Also removes the default RATE_LIMIT_REDIS_URL from the root example since Redis is not part of the local dev compose stack.
The README and local-development guide now tell users to run nvm use before setup if they have nvm installed, matching the existing .nvmrc file that was already in the repo but not referenced in docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Define and run multi-container applications with Docker
Options:
--all-resources Include all resources, even those not
used by services
--ansi string Control when to print ANSI control
characters ("never"|"always"|"auto")
(default "auto")
--compatibility Run compose in backward compatibility mode
--dry-run Execute command in dry run mode
--env-file stringArray Specify an alternate environment file
-f, --file stringArray Compose configuration files
--parallel int Control max parallelism, -1 for
unlimited (default -1)
--profile stringArray Specify a profile to enable
--progress string Set type of progress output (auto,
tty, plain, json, quiet)
--project-directory string Specify an alternate working directory
(default: the path of the, first
specified, Compose file)
-p, --project-name string Project name
Management Commands:
bridge Convert compose files into another model
Commands:
attach Attach local standard input, output, and error streams to a service's running container
build Build or rebuild services
commit Create a new image from a service container's changes
config Parse, resolve and render compose file in canonical format
cp Copy files/folders between a service container and the local filesystem
create Creates containers for a service
down Stop and remove containers, networks
events Receive real time events from containers
exec Execute a command in a running container
export Export a service container's filesystem as a tar archive
images List images used by the created containers
kill Force stop service containers
logs View output from containers
ls List running compose projects
pause Pause services
port Print the public port for a port binding
ps List containers
publish Publish compose application
pull Pull service images
push Push service images
restart Restart service containers
rm Removes stopped service containers
run Run a one-off command on a service
scale Scale services
start Start services
stats Display a live stream of container(s) resource usage statistics
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker Compose version information
volumes List volumes
wait Block until containers of all (or specified) services stop.
watch Watch build context for service and rebuild/refresh containers when files are updated
Run 'docker compose COMMAND --help' for more information on a command. (v2 plugin) or Usage: docker compose [OPTIONS] COMMAND
Define and run multi-container applications with Docker
Options:
--all-resources Include all resources, even those not
used by services
--ansi string Control when to print ANSI control
characters ("never"|"always"|"auto")
(default "auto")
--compatibility Run compose in backward compatibility mode
--dry-run Execute command in dry run mode
--env-file stringArray Specify an alternate environment file
-f, --file stringArray Compose configuration files
--parallel int Control max parallelism, -1 for
unlimited (default -1)
--profile stringArray Specify a profile to enable
--progress string Set type of progress output (auto,
tty, plain, json, quiet)
--project-directory string Specify an alternate working directory
(default: the path of the, first
specified, Compose file)
-p, --project-name string Project name
Management Commands:
bridge Convert compose files into another model
Commands:
attach Attach local standard input, output, and error streams to a service's running container
build Build or rebuild services
commit Create a new image from a service container's changes
config Parse, resolve and render compose file in canonical format
cp Copy files/folders between a service container and the local filesystem
create Creates containers for a service
down Stop and remove containers, networks
events Receive real time events from containers
exec Execute a command in a running container
export Export a service container's filesystem as a tar archive
images List images used by the created containers
kill Force stop service containers
logs View output from containers
ls List running compose projects
pause Pause services
port Print the public port for a port binding
ps List containers
publish Publish compose application
pull Pull service images
push Push service images
restart Restart service containers
rm Removes stopped service containers
run Run a one-off command on a service
scale Scale services
start Start services
stats Display a live stream of container(s) resource usage statistics
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker Compose version information
volumes List volumes
wait Block until containers of all (or specified) services stop.
watch Watch build context for service and rebuild/refresh containers when files are updated
Run 'docker compose COMMAND --help' for more information on a command. (legacy) is available.
Why
A fresh clone into a new directory (or a second worktree) would fail at step 4 because the hardcoded container name collided with an existing one. The env files also had divergent defaults that would break the database connection out of the box.
Verification
�[1m[1/8]�[0m Checking prerequisites
�[32m✓�[0m Node.js v25.9.0
�[32m✓�[0m npm 11.12.1
�[32m✓�[0m Docker is running
�[32m✓�[0m git version 2.50.1 (Apple Git-155)
�[1m[2/8]�[0m Installing dependencies
�[36m→�[0m Installing dependencies (this may take a minute)...
up to date, audited 1168 packages in 2s
344 packages are looking for funding
run
npm fundfor details26 vulnerabilities (15 moderate, 11 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run
npm auditfor details.�[32m✓�[0m Dependencies installed
�[1m[3/8]�[0m Copying environment files
�[36m→�[0m .env already exists, skipping
�[36m→�[0m packages/api/.env already exists, skipping
�[33m⚠�[0m .env: JWT_SECRET is missing or looks like a placeholder
�[33m⚠�[0m packages/api/.env: JWT_SECRET is missing or looks like a placeholder
�[33m⚠�[0m packages/api/.env: ENCRYPTION_KEY is missing or not a 64-character hex string
�[1m[4/8]�[0m Starting Postgres
�[36m→�[0m Starting Postgres via Docker...
�[36m→�[0m Removing existing oricms-postgres container...
�[36m→�[0m Waiting for Postgres to be ready...
.�[32m✓�[0m Postgres is ready
�[1m[5/8]�[0m Building shared package
�[36m→�[0m Building @ori/shared...
�[32m✓�[0m @ori/shared built
�[1m[6/8]�[0m Generating Prisma client
�[36m→�[0m Generating Prisma client...
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
✔ Generated Prisma Client (v5.22.0) to ./../../node_modules/@prisma/client in 64ms
Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)
Tip: Curious about the SQL queries Prisma ORM generates? Optimize helps you enhance your visibility: https://pris.ly/tip-2-optimize
�[32m✓�[0m Prisma client generated
�[1m[7/8]�[0m Running migrations
�[36m→�[0m Running database migrations...
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "oricms", schema "public" at "localhost:5432"
�[31m✗�[0m Command failed: npm run db:migrate -w @ori/api in a fresh worktree
�[1m[1/8]�[0m Checking prerequisites
�[32m✓�[0m Node.js v25.9.0
�[32m✓�[0m npm 11.12.1
�[32m✓�[0m Docker is running
�[32m✓�[0m git version 2.50.1 (Apple Git-155)
�[1m[2/8]�[0m Installing dependencies
�[36m→�[0m Installing dependencies (this may take a minute)...
up to date, audited 1168 packages in 1s
344 packages are looking for funding
run
npm fundfor details26 vulnerabilities (15 moderate, 11 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run
npm auditfor details.�[32m✓�[0m Dependencies installed
�[1m[3/8]�[0m Copying environment files
�[36m→�[0m .env already exists, skipping
�[36m→�[0m packages/api/.env already exists, skipping
�[33m⚠�[0m .env: JWT_SECRET is missing or looks like a placeholder
�[33m⚠�[0m packages/api/.env: JWT_SECRET is missing or looks like a placeholder
�[33m⚠�[0m packages/api/.env: ENCRYPTION_KEY is missing or not a 64-character hex string
�[1m[4/8]�[0m Starting Postgres
�[36m→�[0m Starting Postgres via Docker...
�[36m→�[0m Existing oricms-postgres container is already running; reusing it
�[32m✓�[0m Postgres is ready
�[1m[5/8]�[0m Building shared package
�[36m→�[0m Building @ori/shared...
�[32m✓�[0m @ori/shared built
�[1m[6/8]�[0m Generating Prisma client
�[36m→�[0m Generating Prisma client...
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
✔ Generated Prisma Client (v5.22.0) to ./../../node_modules/@prisma/client in 60ms
Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)
Tip: Easily identify and fix slow SQL queries in your app. Optimize helps you enhance your visibility: https://pris.ly/--optimize
�[32m✓�[0m Prisma client generated
�[1m[7/8]�[0m Running migrations
�[36m→�[0m Running database migrations...
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "oricms", schema "public" at "localhost:5432"
�[31m✗�[0m Command failed: npm run db:migrate -w @ori/api again in the same worktree (should reuse container)
�[1m[1/8]�[0m Checking prerequisites
�[32m✓�[0m Node.js v25.9.0
�[32m✓�[0m npm 11.12.1
�[32m✓�[0m Docker is running
�[32m✓�[0m git version 2.50.1 (Apple Git-155)
�[1m[2/8]�[0m Installing dependencies
�[36m→�[0m Installing dependencies (this may take a minute)...
up to date, audited 1168 packages in 1s
344 packages are looking for funding
run
npm fundfor details26 vulnerabilities (15 moderate, 11 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run
npm auditfor details.�[32m✓�[0m Dependencies installed
�[1m[3/8]�[0m Copying environment files
�[36m→�[0m .env already exists, skipping
�[36m→�[0m packages/api/.env already exists, skipping
�[33m⚠�[0m .env: JWT_SECRET is missing or looks like a placeholder
�[33m⚠�[0m packages/api/.env: JWT_SECRET is missing or looks like a placeholder
�[33m⚠�[0m packages/api/.env: ENCRYPTION_KEY is missing or not a 64-character hex string
�[1m[4/8]�[0m Starting Postgres
�[36m→�[0m Starting Postgres via Docker...
�[36m→�[0m Removing existing oricms-postgres container...
�[36m→�[0m Removing existing database container (--reset-db)...
�[36m→�[0m Waiting for Postgres to be ready...
.�[32m✓�[0m Postgres is ready
�[1m[5/8]�[0m Building shared package
�[36m→�[0m Building @ori/shared...
�[32m✓�[0m @ori/shared built
�[1m[6/8]�[0m Generating Prisma client
�[36m→�[0m Generating Prisma client...
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
✔ Generated Prisma Client (v5.22.0) to ./../../node_modules/@prisma/client in 64ms
Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)
Tip: Need your database queries to be 1000x faster? Accelerate offers you that and more: https://pris.ly/tip-2-accelerate
�[32m✓�[0m Prisma client generated
�[1m[7/8]�[0m Running migrations
�[36m→�[0m Running database migrations...
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "oricms", schema "public" at "localhost:5432"
�[31m✗�[0m Command failed: npm run db:migrate -w @ori/api (should recreate container)
Closes nothing — discovered during local dogfooding.