From 8cbdb6be2e6bbc00ab49acc369074425aaf2ea0e Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Tue, 30 Dec 2025 01:31:56 +0800 Subject: [PATCH] fix(server): docker-compose fix --- apps/server/Dockerfile | 3 ++- apps/server/docker-compose.yml | 23 ++++++++++++++--------- apps/server/sql/init.sql | 1 + 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 apps/server/sql/init.sql diff --git a/apps/server/Dockerfile b/apps/server/Dockerfile index 4a46338bc..a920707d0 100644 --- a/apps/server/Dockerfile +++ b/apps/server/Dockerfile @@ -7,7 +7,8 @@ RUN corepack enable COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ COPY apps/server apps/server -RUN pnpm install --frozen-lockfile --ignore-scripts +RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \ + pnpm install --frozen-lockfile --ignore-scripts EXPOSE 3000 diff --git a/apps/server/docker-compose.yml b/apps/server/docker-compose.yml index 6ea7120ba..38b4accff 100644 --- a/apps/server/docker-compose.yml +++ b/apps/server/docker-compose.yml @@ -1,22 +1,20 @@ -version: '3.9' +name: proj-airi-api-server services: db: - image: postgres:16-alpine - container_name: airi-postgres + image: ghcr.io/tensorchord/vchord-postgres:pg18-v1.0.0 environment: - - POSTGRES_DB=airi - - POSTGRES_USER=airi - - POSTGRES_PASSWORD=airi + - POSTGRES_PASSWORD=example-P@ssw0rd-xHjDYR.b7N ports: - '5432:5432' + volumes: + - ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql + - db_data:/var/lib/postgresql healthcheck: test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB'] interval: 5s timeout: 5s retries: 10 - volumes: - - ${serviceName}_data:/var/lib/postgresql/data server: build: @@ -25,8 +23,15 @@ services: depends_on: db: condition: service_healthy + environment: + - DATABASE_URL=postgresql://postgres:example-P@ssw0rd-xHjDYR.b7N@db:5432/postgres ports: - - '3000:3000' + - '6112:3000' + healthcheck: + test: ['CMD-SHELL', 'curl -f http://localhost:3000/health || exit 1'] + interval: 10s + timeout: 5s + retries: 5 volumes: db_data: diff --git a/apps/server/sql/init.sql b/apps/server/sql/init.sql new file mode 100644 index 000000000..858a86a43 --- /dev/null +++ b/apps/server/sql/init.sql @@ -0,0 +1 @@ +CREATE EXTENSION vchord CASCADE;