Skip to content

Commit add6ee2

Browse files
authored
feat(ccip-server): migrate to Prisma 7 and ncc bundling (#7895)
1 parent d1d90d2 commit add6ee2

11 files changed

Lines changed: 811 additions & 329 deletions

File tree

pnpm-lock.yaml

Lines changed: 762 additions & 170 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/Dockerfile.node-service

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Unified Dockerfile for NCC-bundled TypeScript node services
2-
# Used by: rebalancer, warp-monitor
2+
# Used by: rebalancer, warp-monitor, ccip-server
33
#
44
# Build args (passed from docker-bake.hcl):
55
# SERVICE_DIR - Directory name under typescript/ (e.g., "rebalancer")
66
# SERVICE_PACKAGE - Package name for turbo filter (e.g., "@hyperlane-xyz/rebalancer")
7+
# SERVICE_PORT - Optional HTTP port (default: none, only metrics on 9090)
78

89
FROM node:24-slim AS builder
910

@@ -54,6 +55,13 @@ COPY solidity/package.json ./solidity/
5455
COPY solhint-plugin/package.json ./solhint-plugin/
5556
COPY starknet/package.json ./starknet/
5657

58+
# Copy prisma schema if present (needed for postinstall prisma generate in ccip-server)
59+
RUN --mount=type=bind,source=typescript/${SERVICE_DIR},target=/tmp/service-src \
60+
if [ -d /tmp/service-src/prisma ]; then \
61+
mkdir -p typescript/${SERVICE_DIR} && \
62+
cp -r /tmp/service-src/prisma typescript/${SERVICE_DIR}/prisma; \
63+
fi
64+
5765
RUN pnpm install --frozen-lockfile
5866

5967
# Copy source files
@@ -116,11 +124,13 @@ RUN GCP_LOGGER_VERSION=$(grep "pino-logging-gcp-config" /tmp/pnpm-workspace.yaml
116124

117125
# Environment variables
118126
ARG SERVICE_VERSION=dev
127+
ARG SERVICE_PORT
119128
ENV NODE_ENV=production
120129
ENV LOG_LEVEL=info
121130
ENV SERVICE_VERSION=${SERVICE_VERSION}
131+
ENV SERVER_PORT=${SERVICE_PORT}
122132

123-
# Expose metrics port
133+
# Expose metrics port; service port published at runtime with -p if needed
124134
EXPOSE 9090
125135

126136
# Run the service from the bundle

typescript/ccip-server/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/configs
55
/prisma/dev.db
66
/src/generated
7+
/bundle
78

89
# allow check-in of .env.example
910
!.env.example

typescript/ccip-server/Dockerfile

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

typescript/ccip-server/eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export default [
1717
'**/tests/*',
1818
'src/**/*.js',
1919
'src/generated/**',
20+
'bundle/**',
21+
'prisma/config.ts',
2022
],
2123
},
2224
];

typescript/ccip-server/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"scripts": {
1818
"postinstall": "prisma generate",
1919
"build": "prisma generate && tsc -p tsconfig.json",
20+
"bundle": "rm -rf ./bundle && ncc build ./dist/server.js -o bundle -e @google-cloud/pino-logging-gcp-config && node ../../scripts/ncc.post-bundle.mjs",
2021
"start": "tsx src/server.ts",
2122
"dev": "NODE_ENV=development LOG_FORMAT=pretty tsx watch src/server.ts",
2223
"test": "jest",
@@ -31,9 +32,11 @@
3132
"@types/cors": "^2",
3233
"@types/express": "^4.17.1",
3334
"@types/node": "catalog:",
35+
"@types/pg": "^8.16.0",
3436
"@types/pino-http": "^5.8.4",
3537
"@typescript-eslint/eslint-plugin": "catalog:",
3638
"@typescript-eslint/parser": "catalog:",
39+
"@vercel/ncc": "catalog:",
3740
"eslint": "catalog:",
3841
"eslint-import-resolver-typescript": "catalog:",
3942
"jest": "^29.7.0",
@@ -56,13 +59,15 @@
5659
"@hyperlane-xyz/sdk": "workspace:*",
5760
"@hyperlane-xyz/utils": "workspace:*",
5861
"pino": "catalog:",
59-
"@prisma/client": "^6.8.2",
62+
"@prisma/adapter-pg": "^7.3.0",
63+
"@prisma/client": "^7.3.0",
6064
"cors": "^2.8.5",
6165
"dotenv-flow": "^4.1.0",
6266
"ethers": "catalog:",
6367
"express": "^4.17.1",
68+
"pg": "^8.17.2",
6469
"pino-http": "^8.6.1",
65-
"prisma": "^6.8.2",
70+
"prisma": "^7.3.0",
6671
"prom-client": "catalog:",
6772
"zod": "catalog:"
6873
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig, env } from 'prisma/config';
2+
3+
export default defineConfig({
4+
schema: 'prisma/schema.prisma',
5+
migrations: {
6+
path: 'prisma/migrations',
7+
},
8+
datasource: {
9+
url: env('DATABASE_URL'),
10+
},
11+
});

typescript/ccip-server/prisma/schema.prisma

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
// learn more about it in the docs: https://pris.ly/d/prisma-schema
33

44
generator client {
5-
provider = "prisma-client-js"
5+
provider = "prisma-client"
66
output = "../src/generated/prisma"
77
}
88

9-
// DATABASE_URL is required for prisma generate but actual connection is handled in code
9+
// DATABASE_URL is now configured in prisma.config.ts (Prisma 7 requirement)
1010
datasource db {
1111
provider = "postgresql"
12-
url = env("DATABASE_URL")
1312
}
1413

1514
model Commitment {

typescript/ccip-server/src/db.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import { PrismaPg } from '@prisma/adapter-pg';
2+
import pg from 'pg';
3+
14
import { PrismaClient } from './generated/prisma/client.js';
25

3-
export const prisma = new PrismaClient();
6+
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
7+
const adapter = new PrismaPg(pool);
8+
export const prisma = new PrismaClient({ adapter });

typescript/ccip-server/turbo.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"extends": ["//"],
33
"tasks": {
4-
"build": {
5-
"outputs": ["dist/**", "src/generated/**"]
4+
"bundle": {
5+
"dependsOn": ["build"],
6+
"outputs": ["bundle/**"]
67
}
78
}
89
}

0 commit comments

Comments
 (0)