Skip to content

Commit 1cb2d2f

Browse files
NodeJS apps: reference-data and trade-feed: decrease container size and improve security posture (#258)
* Optimized Dockerfile for reference-data Signed-off-by: Mathieu Benoit <mathieu-benoit@hotmail.fr> * Optimized Dockerfile for trade-feed Signed-off-by: Mathieu Benoit <mathieu-benoit@hotmail.fr> --------- Signed-off-by: Mathieu Benoit <mathieu-benoit@hotmail.fr>
1 parent c64ea9d commit 1cb2d2f

File tree

4 files changed

+22
-145
lines changed

4 files changed

+22
-145
lines changed

reference-data/Dockerfile

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
2-
ARG VARIANT=16-bullseye
3-
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
1+
FROM --platform=$BUILDPLATFORM node:23 AS builder
2+
WORKDIR /usr/src/app
3+
COPY package*.json ./
4+
RUN npm install --only=production
5+
COPY . .
6+
RUN npm run build
47

5-
WORKDIR /reference-data
8+
FROM alpine:3.21
9+
RUN apk add --no-cache nodejs
10+
WORKDIR /usr/src/app
11+
COPY --from=builder /usr/src/app/dist ./dist
12+
COPY --from=builder /usr/src/app/node_modules ./node_modules
613
COPY . .
714
EXPOSE 18085
8-
9-
# [Optional] Uncomment this section to install additional OS packages.
10-
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
11-
# && apt-get -y install --no-install-recommends <your-package-list-here>
12-
13-
# [Optional] Uncomment if you want to install an additional version of node using nvm
14-
ARG EXTRA_NODE_VERSION=18
15-
RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
16-
17-
# [Optional] Uncomment if you want to install more global node modules
18-
# RUN su node -c "npm install -g <your-package-list-here>"
19-
RUN npm install
20-
ENTRYPOINT npm run start
15+
CMD [ "node", "dist/main"]

reference-data/base.Dockerfile

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

trade-feed/Dockerfile

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
2-
ARG VARIANT=16-bullseye
3-
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
4-
5-
WORKDIR /trade-feed
1+
FROM --platform=$BUILDPLATFORM node:23 AS builder
2+
WORKDIR /usr/src/app
3+
COPY package*.json ./
4+
RUN npm install --only=production
5+
6+
FROM alpine:3.21
7+
RUN apk add --no-cache nodejs
8+
WORKDIR /usr/src/app
9+
COPY --from=builder /usr/src/app/node_modules ./node_modules
610
COPY . .
711
EXPOSE 18086
8-
9-
# [Optional] Uncomment this section to install additional OS packages.
10-
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
11-
# && apt-get -y install --no-install-recommends <your-package-list-here>
12-
13-
# [Optional] Uncomment if you want to install an additional version of node using nvm
14-
ARG EXTRA_NODE_VERSION=18
15-
RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
16-
17-
# [Optional] Uncomment if you want to install more global node modules
18-
# RUN su node -c "npm install -g <your-package-list-here>"
19-
RUN npm install
20-
ENTRYPOINT npm run start
12+
ENTRYPOINT [ "node", "index.js" ]

trade-feed/base.Dockerfile

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

0 commit comments

Comments
 (0)