From a385ac00b1bcaca0f6f91a2217b7f98c7ae4b565 Mon Sep 17 00:00:00 2001 From: Vasil Sudakou Date: Mon, 23 Dec 2024 03:15:38 +0300 Subject: [PATCH] feat: modify Dockerfile for typescript --- Dockerfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 545b505..7f20c02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ RUN adduser --disabled-password -home /home/cfu -shell /bin/bash cfu WORKDIR /root/cf-runtime COPY package.json yarn.lock ./ -FROM base AS dependencies +FROM base AS build-dependencies RUN apt-get update \ && apt upgrade -y \ && apt-get install -y \ @@ -11,14 +11,22 @@ RUN apt-get update \ git \ make \ python3 + +FROM build-dependencies AS build +RUN yarn install --frozen-lockfile +COPY . . +RUN yarn build + +FROM build-dependencies AS prod-dependencies RUN yarn install --frozen-lockfile --production FROM base AS production -COPY --from=dependencies /root/cf-runtime/node_modules ./node_modules +COPY --from=prod-dependencies /root/cf-runtime/node_modules ./node_modules +COPY --from=build /root/cf-runtime/dist ./dist COPY . . #purpose of security RUN npm -g uninstall npm USER cfu -CMD ["node", "lib/index.js"] +CMD ["node", "dist/index.js"]