From 44816bbcdbe07018b5d240334a627c6ce7ecb3aa Mon Sep 17 00:00:00 2001 From: Zhenya Tikhonov Date: Wed, 3 Jul 2024 12:19:45 +0400 Subject: [PATCH 1/2] build: reduce image size; upgrade node --- Dockerfile | 33 ++++++++++++++------------------- service.yaml | 2 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 40d60c5..5f4ede2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,21 @@ -FROM node:20.8.1-bookworm-slim - +FROM node:20.15.0-bookworm-slim as base +RUN adduser --disabled-password -home /home/cfu -shell /bin/bash cfu WORKDIR /root/cf-runtime - -RUN apt-get update && apt upgrade -y && \ - apt-get install g++ git make python3 -y - COPY package.json yarn.lock ./ -# install cf-runtime required binaries -RUN yarn install --frozen-lockfile --production && \ - yarn cache clean && \ - apt-get purge g++ git make python3 -y && \ - apt-get autoremove -y && \ - apt-get clean -y && \ - rm -rf /tmp/* && \ - rm -rf /var/lib/apt/lists/* +FROM base AS dependencies +RUN apt-get update \ + && apt upgrade -y \ + && apt-get install -y \ + g++ \ + git \ + make \ + python3 +RUN yarn install --frozen-lockfile --production -# copy app files -COPY . ./ - -RUN adduser --disabled-password -home /home/cfu -shell /bin/bash cfu +FROM base AS production +COPY --from=dependencies /root/cf-runtime/node_modules ./node_modules +COPY . . USER cfu - CMD ["node", "lib/index.js"] diff --git a/service.yaml b/service.yaml index e3f2b26..289d6e4 100644 --- a/service.yaml +++ b/service.yaml @@ -1 +1 @@ -version: 1.11.4 +version: 1.11.5 From 7a8812be876b63c37c2763c469ac389bca5dd173 Mon Sep 17 00:00:00 2001 From: Zhenya Tikhonov Date: Wed, 3 Jul 2024 15:36:45 +0400 Subject: [PATCH 2/2] build(Dockerfile): fix `as` casing --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5f4ede2..862d46a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20.15.0-bookworm-slim as base +FROM node:20.15.0-bookworm-slim AS base RUN adduser --disabled-password -home /home/cfu -shell /bin/bash cfu WORKDIR /root/cf-runtime COPY package.json yarn.lock ./