From 0ca39848a70933ef4dfcc7911febaf05051b4cb1 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 01:33:21 +0000 Subject: [PATCH 01/18] Bumping drift-common to 2d02f79b97fead33359a091c38b84dd073b71525 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 06495bf..2d02f79 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 06495bf9d730318000db020ed857dc77f2171fcc +Subproject commit 2d02f79b97fead33359a091c38b84dd073b71525 From 5a7a0dbe4b28ff3972743cff967c05e869d4c576 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 19:20:35 +0000 Subject: [PATCH 02/18] Bumping drift-common to 45bcef96accc9b68389f04a1b399acaf3a8ec334 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 2d02f79..45bcef9 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 2d02f79b97fead33359a091c38b84dd073b71525 +Subproject commit 45bcef96accc9b68389f04a1b399acaf3a8ec334 From 6b7534df38a2968c28f9ab969bc28707ce790ed6 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 21:26:59 +0000 Subject: [PATCH 03/18] Bumping drift-common to 3c63a041b4bfcf41efc5462eda381f1a3d94bfe4 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 45bcef9..3c63a04 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 45bcef96accc9b68389f04a1b399acaf3a8ec334 +Subproject commit 3c63a041b4bfcf41efc5462eda381f1a3d94bfe4 From 177ee11513be66c1609122a728c22e12c5469b56 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 21:46:36 +0000 Subject: [PATCH 04/18] Bumping drift-common to bf8209fd39520965ef52b5a30d685cf61a5b74a2 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 3c63a04..bf8209f 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 3c63a041b4bfcf41efc5462eda381f1a3d94bfe4 +Subproject commit bf8209fd39520965ef52b5a30d685cf61a5b74a2 From 72444ec59a8f63479f02afc0ab0a4c6ba614ef28 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 19:15:11 +0000 Subject: [PATCH 05/18] Bumping drift-common to dd61ef0994cf5bbc892eec30c3d1610bbafbe1fe --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index bf8209f..dd61ef0 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit bf8209fd39520965ef52b5a30d685cf61a5b74a2 +Subproject commit dd61ef0994cf5bbc892eec30c3d1610bbafbe1fe From 58d3c9e61eab268ca45cd6c8a79705e2b719d373 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 19:46:15 +0000 Subject: [PATCH 06/18] Bumping drift-common to 795b91912f1831533846938bb5124c6d7ffbf829 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index dd61ef0..795b919 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit dd61ef0994cf5bbc892eec30c3d1610bbafbe1fe +Subproject commit 795b91912f1831533846938bb5124c6d7ffbf829 From 61dff2651253ef01cb12f33c966924917b34dbe8 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 20:45:42 +0000 Subject: [PATCH 07/18] Bumping drift-common to 279453bf6a05e30c9eff7d0f5ca45f911a367d96 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 795b919..279453b 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 795b91912f1831533846938bb5124c6d7ffbf829 +Subproject commit 279453bf6a05e30c9eff7d0f5ca45f911a367d96 From 9b7bbe93faa52f5e167fdab595a64eb3f48e75e2 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 21:44:03 +0000 Subject: [PATCH 08/18] Bumping drift-common to d07ed2250d8e7925eb33765ceaeacc7853a372f2 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 279453b..d07ed22 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 279453bf6a05e30c9eff7d0f5ca45f911a367d96 +Subproject commit d07ed2250d8e7925eb33765ceaeacc7853a372f2 From fb9ec09d7ea688f92b691365908396dc52391b20 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:12:50 +0000 Subject: [PATCH 09/18] Bumping drift-common to 4355326cf943ea7f20203d51f2875ff5dc07f1f7 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index d07ed22..4355326 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit d07ed2250d8e7925eb33765ceaeacc7853a372f2 +Subproject commit 4355326cf943ea7f20203d51f2875ff5dc07f1f7 From 29e32ddf41e87278c306b4b2afd649f056acdc8d Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:08:43 +0000 Subject: [PATCH 10/18] Bumping drift-common to eaca2ae34b976b498e43b260ed3785aed296cf41 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 4355326..eaca2ae 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 4355326cf943ea7f20203d51f2875ff5dc07f1f7 +Subproject commit eaca2ae34b976b498e43b260ed3785aed296cf41 From a4adf3504b046af98fb8a2e29234fb5fc2d25b61 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 22:36:26 +0000 Subject: [PATCH 11/18] Bumping drift-common to 5fca3629efa3ab839f8f619d2d94d8d361dd2aa3 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index eaca2ae..5fca362 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit eaca2ae34b976b498e43b260ed3785aed296cf41 +Subproject commit 5fca3629efa3ab839f8f619d2d94d8d361dd2aa3 From 4f02f91b8b59d11383c50ceebde1fa6b2c4f7954 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 23:23:21 +0000 Subject: [PATCH 12/18] Bumping drift-common to 658553e82bb942ce01c0cf570c7ad8f246c15187 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 5fca362..658553e 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 5fca3629efa3ab839f8f619d2d94d8d361dd2aa3 +Subproject commit 658553e82bb942ce01c0cf570c7ad8f246c15187 From 83bc842e7d3854ab85ee4bded901a6de3d1f650d Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 01:29:03 +0000 Subject: [PATCH 13/18] Bumping drift-common to b70b55e410cb0a0647a69fbe92f588ee201e0de9 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 658553e..b70b55e 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 658553e82bb942ce01c0cf570c7ad8f246c15187 +Subproject commit b70b55e410cb0a0647a69fbe92f588ee201e0de9 From 4227c6b54653e1e50e663c042971d60505b41630 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Tue, 17 Dec 2024 12:12:43 +0800 Subject: [PATCH 14/18] shrink docker image / esbuildify (#319) multistage docker build + esbuild --- .dockerignore | 4 ++++ Dockerfile | 41 +++++++++++++++++++++++++++++------------ esbuild.config.js | 28 ++++++++++++++++++++++++++++ package.json | 5 +++-- 4 files changed, 64 insertions(+), 14 deletions(-) create mode 100644 .dockerignore create mode 100644 esbuild.config.js diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..60736c5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +*/**/node_modules/ +*/**/lib +.husky/ +node_modules/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 629a61e..68ab595 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,36 @@ -FROM public.ecr.aws/bitnami/node:20.18.1 -RUN apt-get install git -ENV NODE_ENV=production -RUN npm install -g typescript +FROM node:20.18.1 AS builder WORKDIR /app -COPY drift-common /app/drift-common -COPY . . + +# Copy package files first to leverage cache +COPY package.json yarn.lock ./ +COPY drift-common/protocol/sdk/package.json ./drift-common/protocol/sdk/ +COPY drift-common/common-ts/package.json ./drift-common/common-ts/ + +RUN npm install -g bun typescript husky + WORKDIR /app/drift-common/protocol/sdk -RUN yarn -RUN yarn build +COPY drift-common/protocol/sdk/ . +RUN bun install --production && bun run build + WORKDIR /app/drift-common/common-ts -RUN yarn -RUN yarn build +COPY drift-common/common-ts/ . +RUN bun install --production && bun run build + WORKDIR /app -RUN yarn -RUN yarn build +COPY . . +# no '--production' for esbuild +RUN bun install && bun esbuild.config.js + +FROM node:20.18.1-alpine +# 'bigint-buffer' native lib for performance +# @triton-one/yellowstone-grpc so .wasm lib included +RUN apk add python3 make g++ --virtual .build &&\ + npm install -C /lib bigint-buffer @triton-one/yellowstone-grpc &&\ + apk del .build +COPY --from=builder /app/lib/ ./lib/ +ENV NODE_ENV=production EXPOSE 9464 + +CMD ["node", "./lib/index.js"] \ No newline at end of file diff --git a/esbuild.config.js b/esbuild.config.js new file mode 100644 index 0000000..6576824 --- /dev/null +++ b/esbuild.config.js @@ -0,0 +1,28 @@ +const esbuild = require('esbuild'); +const glob = require('tiny-glob'); + +const commonConfig = { + bundle: true, + platform: 'node', + target: 'node20', + sourcemap: false, + // minify: true, makes messy debug/error output + treeShaking: true, + legalComments: 'none', + mainFields: ['module', 'main'], + metafile: true, + format: 'cjs', + external: [ + 'bigint-buffer', + '@triton-one/yellowstone-grpc' + ] +}; + +(async () => { + let entryPoints = await glob("./src/*.ts", { filesOnly: true }); + await esbuild.build({ + ...commonConfig, + entryPoints, + outdir: 'lib', + }); +})().catch(() => process.exit(1)); \ No newline at end of file diff --git a/package.json b/package.json index 6765ccd..2976c56 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "license": "Apache-2.0", "dependencies": { "@coral-xyz/anchor": "^0.29.0", - "@drift/common": "file:./drift-common/common-ts", "@drift-labs/sdk": "file:./drift-common/protocol/sdk", + "@drift/common": "file:./drift-common/common-ts", "@opentelemetry/api": "^1.1.0", "@opentelemetry/auto-instrumentations-node": "^0.31.1", "@opentelemetry/exporter-prometheus": "^0.31.0", @@ -33,7 +33,6 @@ "response-time": "^2.3.2", "rxjs": "^7.8.1", "socket.io-redis": "^6.1.1", - "typescript": "4.5.4", "undici": "^6.16.1", "winston": "^3.8.1", "ws": "^8.14.2" @@ -42,12 +41,14 @@ "@types/k6": "^0.45.0", "@typescript-eslint/eslint-plugin": "^4.28.0", "@typescript-eslint/parser": "^4.28.0", + "esbuild": "^0.24.0", "eslint": "^7.29.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^3.4.0", "husky": "^7.0.4", "k6": "^0.0.0", "prettier": "^2.4.1", + "tiny-glob": "^0.2.9", "ts-node": "^10.9.1" }, "scripts": { From da0ef7b39295bd74189f21d7d37cb444ca861400 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Tue, 17 Dec 2024 12:16:24 +0800 Subject: [PATCH 15/18] fix --forzen-lockfile issue in Docker build --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 68ab595..70cf3b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN bun install --production && bun run build WORKDIR /app/drift-common/common-ts COPY drift-common/common-ts/ . -RUN bun install --production && bun run build +RUN bun install && bun run build WORKDIR /app COPY . . From 5cf15f51331d7224991e97793f3775d1ae154323 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Tue, 17 Dec 2024 12:18:28 +0800 Subject: [PATCH 16/18] fix --frozen-lockfile issue in Docker build (again) --- Dockerfile | 2 +- drift-common | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 70cf3b6..2b4a453 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN npm install -g bun typescript husky WORKDIR /app/drift-common/protocol/sdk COPY drift-common/protocol/sdk/ . -RUN bun install --production && bun run build +RUN bun install && bun run build WORKDIR /app/drift-common/common-ts COPY drift-common/common-ts/ . diff --git a/drift-common b/drift-common index b70b55e..bf8209f 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit b70b55e410cb0a0647a69fbe92f588ee201e0de9 +Subproject commit bf8209fd39520965ef52b5a30d685cf61a5b74a2 From 9c6c65e921c0231d9450f39aa4706a454fffb1a6 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Tue, 17 Dec 2024 12:32:04 +0800 Subject: [PATCH 17/18] esbuild subdir entrypoints --- esbuild.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esbuild.config.js b/esbuild.config.js index 6576824..b269b11 100644 --- a/esbuild.config.js +++ b/esbuild.config.js @@ -19,10 +19,10 @@ const commonConfig = { }; (async () => { - let entryPoints = await glob("./src/*.ts", { filesOnly: true }); + let entryPoints = await glob("./src/**/*.ts"); await esbuild.build({ ...commonConfig, entryPoints, outdir: 'lib', }); -})().catch(() => process.exit(1)); \ No newline at end of file +})().catch(() => process.exit(1)); From d8b79bfbd3a1b5478e9bafb9e9bcaa8141fc9456 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:23:18 +0000 Subject: [PATCH 18/18] Bumping drift-common to 24c4310ab1e306ae3974a355fa5f3561b03db07a --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index bf8209f..24c4310 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit bf8209fd39520965ef52b5a30d685cf61a5b74a2 +Subproject commit 24c4310ab1e306ae3974a355fa5f3561b03db07a