Skip to content

Commit bb5f40a

Browse files
authored
feat(pg): added ability to customize postgres port when running containerized app (#1173)
1 parent 5ae5429 commit bb5f40a

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

.devcontainer/docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ services:
99
command: sleep infinity
1010
environment:
1111
- NODE_ENV=development
12-
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
13-
- POSTGRES_URL=postgresql://postgres:postgres@db:5432/simstudio
12+
- DATABASE_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
13+
- POSTGRES_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
1414
- BETTER_AUTH_URL=http://localhost:3000
1515
- NEXT_PUBLIC_APP_URL=http://localhost:3000
1616
- BUN_INSTALL_CACHE_DIR=/home/bun/.bun/cache
@@ -39,7 +39,7 @@ services:
3939
command: sleep infinity
4040
environment:
4141
- NODE_ENV=development
42-
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
42+
- DATABASE_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
4343
- BETTER_AUTH_URL=http://localhost:3000
4444
- NEXT_PUBLIC_APP_URL=http://localhost:3000
4545
depends_on:
@@ -60,7 +60,7 @@ services:
6060
context: ..
6161
dockerfile: docker/db.Dockerfile
6262
environment:
63-
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
63+
- DATABASE_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
6464
depends_on:
6565
db:
6666
condition: service_healthy
@@ -77,7 +77,7 @@ services:
7777
- POSTGRES_PASSWORD=postgres
7878
- POSTGRES_DB=simstudio
7979
ports:
80-
- "5432:5432"
80+
- "${POSTGRES_PORT:-5432}:5432"
8181
healthcheck:
8282
test: ["CMD-SHELL", "pg_isready -U postgres"]
8383
interval: 5s

apps/sim/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Database (Required)
22
DATABASE_URL="postgresql://postgres:password@localhost:5432/postgres"
33

4+
# PostgreSQL Port (Optional) - defaults to 5432 if not specified
5+
# POSTGRES_PORT=5432
6+
47
# Authentication (Required)
58
BETTER_AUTH_SECRET=your_secret_key # Use `openssl rand -hex 32` to generate, or visit https://www.better-auth.com/docs/installation
69
BETTER_AUTH_URL=http://localhost:3000

docker-compose.local.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
limits:
1111
memory: 8G
1212
environment:
13-
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
13+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-simstudio}
1414
- BETTER_AUTH_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
1515
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
1616
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your_auth_secret_here}
@@ -41,7 +41,7 @@ services:
4141
context: .
4242
dockerfile: docker/realtime.Dockerfile
4343
environment:
44-
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
44+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-simstudio}
4545
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
4646
- BETTER_AUTH_URL=${BETTER_AUTH_URL:-http://localhost:3000}
4747
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your_auth_secret_here}
@@ -67,7 +67,7 @@ services:
6767
context: .
6868
dockerfile: docker/db.Dockerfile
6969
environment:
70-
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
70+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-simstudio}
7171
depends_on:
7272
db:
7373
condition: service_healthy
@@ -78,7 +78,7 @@ services:
7878
image: pgvector/pgvector:pg17
7979
restart: always
8080
ports:
81-
- '5432:5432'
81+
- '${POSTGRES_PORT:-5432}:5432'
8282
environment:
8383
- POSTGRES_USER=${POSTGRES_USER:-postgres}
8484
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}

docker-compose.ollama.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
limits:
1414
memory: 8G
1515
environment:
16-
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
16+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-simstudio}
1717
- BETTER_AUTH_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
1818
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
1919
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-sim_auth_secret_$(openssl rand -hex 16)}
@@ -43,7 +43,7 @@ services:
4343
context: .
4444
dockerfile: docker/realtime.Dockerfile
4545
environment:
46-
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
46+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-simstudio}
4747
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
4848
- BETTER_AUTH_URL=${BETTER_AUTH_URL:-http://localhost:3000}
4949
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-sim_auth_secret_$(openssl rand -hex 16)}
@@ -70,7 +70,7 @@ services:
7070
context: .
7171
dockerfile: docker/db.Dockerfile
7272
environment:
73-
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
73+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-simstudio}
7474
depends_on:
7575
db:
7676
condition: service_healthy
@@ -82,7 +82,7 @@ services:
8282
image: pgvector/pgvector:pg17
8383
restart: always
8484
ports:
85-
- '5432:5432'
85+
- '${POSTGRES_PORT:-5432}:5432'
8686
environment:
8787
- POSTGRES_USER=${POSTGRES_USER:-postgres}
8888
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}

docker-compose.prod.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
limits:
1010
memory: 8G
1111
environment:
12-
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
12+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-simstudio}
1313
- BETTER_AUTH_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
1414
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
1515
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your_auth_secret_here}
@@ -46,7 +46,7 @@ services:
4646
limits:
4747
memory: 4G
4848
environment:
49-
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
49+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-simstudio}
5050
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
5151
- BETTER_AUTH_URL=${BETTER_AUTH_URL:-http://localhost:3000}
5252
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your_auth_secret_here}
@@ -63,7 +63,7 @@ services:
6363
migrations:
6464
image: ghcr.io/simstudioai/migrations:latest
6565
environment:
66-
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
66+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-simstudio}
6767
depends_on:
6868
db:
6969
condition: service_healthy
@@ -74,7 +74,7 @@ services:
7474
image: pgvector/pgvector:pg17
7575
restart: unless-stopped
7676
ports:
77-
- '5432:5432'
77+
- '${POSTGRES_PORT:-5432}:5432'
7878
environment:
7979
- POSTGRES_USER=${POSTGRES_USER:-postgres}
8080
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}

0 commit comments

Comments
 (0)