Skip to content

Commit dcf6e10

Browse files
authored
fix(docker): added pgvector image to docker builds, modified push to migrate to ameliorate vector data type issue (#452)
* added pgvector image to docker builds, modified push to migrate to ameliorate vector data type issue * added zod and t3-ss/env-nextjs to minimal set of dependencies for db image * added healthcheck to docker services
1 parent d9e99a4 commit dcf6e10

File tree

9 files changed

+374
-415
lines changed

9 files changed

+374
-415
lines changed

.devcontainer/docker-compose.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,33 @@ services:
1717
depends_on:
1818
db:
1919
condition: service_healthy
20+
migrations:
21+
condition: service_completed_successfully
2022
ports:
2123
- "3000:3000"
2224
- "3001:3001"
2325
working_dir: /workspace
26+
healthcheck:
27+
test: ['CMD', 'wget', '--spider', '--quiet', 'http://127.0.0.1:3000']
28+
interval: 90s
29+
timeout: 5s
30+
retries: 3
31+
start_period: 10s
32+
33+
migrations:
34+
build:
35+
context: ..
36+
dockerfile: docker/db.Dockerfile
37+
environment:
38+
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
39+
depends_on:
40+
db:
41+
condition: service_healthy
42+
command: ['bun', 'run', 'db:migrate']
43+
restart: 'no'
2444

2545
db:
26-
image: postgres:17-alpine
46+
image: pgvector/pgvector:pg17
2747
restart: unless-stopped
2848
volumes:
2949
- postgres-data:/var/lib/postgresql/data

apps/sim/db/migrations/0000_careless_black_knight.sql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
-- Current sql file was generated after introspecting the database
2-
-- If you want to run this migration please uncomment this code before executing migrations
3-
/*
2+
43
CREATE TABLE "verification" (
54
"id" text PRIMARY KEY NOT NULL,
65
"identifier" text NOT NULL,
@@ -50,5 +49,4 @@ CREATE TABLE "session" (
5049
);
5150
--> statement-breakpoint
5251
ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
53-
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
54-
*/
52+
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;

apps/sim/db/migrations/0006_plain_zzzax.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ALTER TABLE "user_settings" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint
2929
DROP TABLE "logs" CASCADE;--> statement-breakpoint
3030
DROP TABLE "user_environment" CASCADE;--> statement-breakpoint
3131
DROP TABLE "user_settings" CASCADE;--> statement-breakpoint
32-
ALTER TABLE "workflow" ALTER COLUMN "state" SET DATA TYPE json;--> statement-breakpoint
32+
ALTER TABLE "workflow" ALTER COLUMN "state" SET DATA TYPE json USING state::json;--> statement-breakpoint
3333
ALTER TABLE "workflow_logs" ADD CONSTRAINT "workflow_logs_workflow_id_workflow_id_fk" FOREIGN KEY ("workflow_id") REFERENCES "public"."workflow"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
3434
ALTER TABLE "settings" ADD CONSTRAINT "settings_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
3535
ALTER TABLE "environment" ADD CONSTRAINT "environment_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;

bun.lock

Lines changed: 326 additions & 399 deletions
Large diffs are not rendered by default.

docker-compose.local.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ services:
2727
condition: service_healthy
2828
migrations:
2929
condition: service_completed_successfully
30+
healthcheck:
31+
test: ['CMD', 'wget', '--spider', '--quiet', 'http://127.0.0.1:3000']
32+
interval: 90s
33+
timeout: 5s
34+
retries: 3
35+
start_period: 10s
3036

3137
migrations:
3238
build:
@@ -35,12 +41,13 @@ services:
3541
environment:
3642
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
3743
depends_on:
38-
- db
39-
command: ['bun', 'run', 'db:push']
44+
db:
45+
condition: service_healthy
46+
command: ['bun', 'run', 'db:migrate']
4047
restart: 'no'
4148

4249
db:
43-
image: postgres:17-alpine
50+
image: pgvector/pgvector:pg17
4451
restart: always
4552
ports:
4653
- '5432:5432'

docker-compose.prod.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,25 @@ services:
2626
condition: service_healthy
2727
migrations:
2828
condition: service_completed_successfully
29+
healthcheck:
30+
test: ['CMD', 'wget', '--spider', '--quiet', 'http://127.0.0.1:3000']
31+
interval: 90s
32+
timeout: 5s
33+
retries: 3
34+
start_period: 10s
2935

3036
migrations:
3137
image: ghcr.io/simstudioai/migrations:latest
3238
environment:
3339
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-simstudio}
3440
depends_on:
35-
- db
36-
command: ['bun', 'run', 'db:push']
41+
db:
42+
condition: service_healthy
43+
command: ['bun', 'run', 'db:migrate']
3744
restart: 'no'
3845

3946
db:
40-
image: postgres:17-alpine
47+
image: pgvector/pgvector:pg17
4148
restart: unless-stopped
4249
ports:
4350
- '5432:5432'

docker/db.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY apps/sim/package.json ./apps/sim/db/
1010

1111
# Install minimal dependencies in one layer
1212
RUN bun install --omit dev --ignore-scripts && \
13-
bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres next-runtime-env
13+
bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres next-runtime-env zod @t3-oss/env-nextjs
1414

1515
# ========================================
1616
# Runner Stage: Production Environment

packages/simstudio/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simstudio",
3-
"version": "0.1.17",
3+
"version": "0.1.18",
44
"description": "Sim Studio CLI - Run Sim Studio with a single command",
55
"main": "dist/index.js",
66
"bin": {

packages/simstudio/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function main() {
101101
if (options.pull) {
102102
await pullImage('ghcr.io/simstudioai/simstudio:latest')
103103
await pullImage('ghcr.io/simstudioai/migrations:latest')
104-
await pullImage('postgres:17-alpine')
104+
await pullImage('pgvector/pgvector:pg17')
105105
}
106106

107107
// Ensure Docker network exists
@@ -144,7 +144,7 @@ async function main() {
144144
`${dataDir}/postgres:/var/lib/postgresql/data`,
145145
'-p',
146146
'5432:5432',
147-
'postgres:17-alpine',
147+
'pgvector/pgvector:pg17',
148148
])
149149

150150
if (!dbSuccess) {

0 commit comments

Comments
 (0)