Skip to content

Commit

Permalink
esbuildify again
Browse files Browse the repository at this point in the history
fix issues from #new-listing-dev thread
use yarn workspaces for package install
  • Loading branch information
jordy25519 committed Dec 18, 2024
1 parent b129bfe commit 8bea223
Show file tree
Hide file tree
Showing 5 changed files with 299 additions and 103 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*/**/node_modules/
*/**/lib/
*/**/tests/
.husky/
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
FROM public.ecr.aws/bitnami/node:20.18.1
RUN apt-get install git
ENV NODE_ENV=production
RUN npm install -g typescript
FROM public.ecr.aws/docker/library/node:20 AS builder

RUN npm install -g typescript bun
WORKDIR /app
COPY drift-common /app/drift-common

COPY . .
RUN bun install
WORKDIR /app/drift-common/protocol/sdk
RUN yarn
RUN yarn build
WORKDIR /app/drift-common/common-ts
RUN yarn
RUN yarn build
WORKDIR /app
RUN yarn
RUN yarn build
RUN bun esbuild.config.js

FROM public.ecr.aws/docker/library/node:20-alpine
COPY --from=builder /app/lib/ ./lib/
RUN apk add --virtual .build python3 g++ make &&\
npm install -C lib bigint-buffer @triton-one/[email protected] &&\
apk del .build &&\
rm -rf /root/.cache/ /root/.npm /usr/local/lib/node_modules

ENV NODE_ENV=production
EXPOSE 9464
27 changes: 27 additions & 0 deletions esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const esbuild = require('esbuild');
const glob = require('tiny-glob');

const commonConfig = {
bundle: true,
platform: 'node',
target: 'node20',
sourcemap: false,
minify: false, // makes messy debug/error output
treeShaking: true,
legalComments: 'none',
metafile: true,
format: 'cjs',
external: [
'bigint-buffer',
'@triton-one/yellowstone-grpc'
]
};

(async () => {
let entryPoints = await glob("./src/**/*.ts");
await esbuild.build({
...commonConfig,
entryPoints,
outdir: 'lib',
});
})().catch(() => process.exit(1));
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -42,12 +42,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": {
Expand All @@ -72,5 +74,9 @@
"lint": "eslint . --ext ts --quiet",
"lint:fix": "eslint . --ext ts --fix",
"playground": "ts-node src/playground.ts"
}
},
"workspaces": [
"drift-common/protocol/sdk",
"drift-common/common-ts"
]
}
Loading

0 comments on commit 8bea223

Please sign in to comment.