-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* shrink docker image (esbuild + multistage docker build)
- Loading branch information
1 parent
8eec5cc
commit 9f85765
Showing
4 changed files
with
49 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
FROM public.ecr.aws/bitnami/node:18 | ||
RUN apt-get install git | ||
ENV NODE_ENV=production | ||
RUN npm install -g typescript | ||
FROM node:18 AS builder | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
# Install build dependencies | ||
RUN apt update -y && apt install git build-essential make python3 -y | ||
# 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/ | ||
|
||
ENV NODE_ENV=production | ||
|
||
WORKDIR /app/drift-common/protocol/sdk | ||
RUN yarn | ||
RUN yarn build | ||
COPY drift-common/protocol/sdk/ . | ||
RUN yarn && yarn build | ||
|
||
WORKDIR /app/drift-common/common-ts | ||
RUN yarn | ||
RUN yarn build | ||
COPY drift-common/common-ts/ . | ||
RUN yarn && yarn build | ||
|
||
WORKDIR /app | ||
RUN yarn | ||
RUN yarn build | ||
COPY . . | ||
RUN yarn && yarn build | ||
|
||
FROM node:18-alpine | ||
COPY --from=builder /app/dist/ ./lib/ | ||
|
||
ENV NODE_ENV=production | ||
EXPOSE 9464 | ||
|
||
CMD [ "yarn", "start" ] | ||
CMD ["node", "./lib/index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const esbuild = require('esbuild'); | ||
|
||
const commonConfig = { | ||
bundle: true, | ||
platform: 'node', | ||
target: 'node18', | ||
sourcemap: true, | ||
// minify: true, makes messy debug/error output | ||
treeShaking: true, | ||
legalComments: 'none', | ||
mainFields: ['module', 'main'], | ||
metafile: true, | ||
format: 'cjs' | ||
}; | ||
|
||
esbuild.build({ | ||
...commonConfig, | ||
entryPoints: ['src/index.ts', 'src/wsConnectionManager.ts'], | ||
outdir: 'dist', | ||
}).catch(() => process.exit(1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters