From 83a4bc3fddcee5bf595636640a79c6799c090774 Mon Sep 17 00:00:00 2001 From: ytshih Date: Fri, 30 Aug 2024 13:57:55 +0000 Subject: [PATCH] Fix Dockerfile --- Dockerfile | 14 +++++++++----- package.json | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 626c291..710b6ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ -FROM node:22.4-slim +FROM node:22.4-slim AS build WORKDIR /work -COPY ./package.json ./package-lock.json . -RUN npm install -COPY ./ . -CMD ["npx", "ts-node", "index.ts"] +COPY . /work +RUN npm ci && npm run build + +FROM gcr.io/distroless/nodejs22-debian12 +WORKDIR /work +COPY --from=build /work /work + +CMD ["index.js"] diff --git a/package.json b/package.json index 80fc25f..8d4142b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,9 @@ "version": "1.0.1", "main": "index.ts", "scripts": { - "test": "ts-node index.ts" + "test": "ts-node index.ts", + "build": "npx tsc --build", + "clean": "npx tsc --build --clean" }, "repository": { "type": "git",