diff --git a/Dockerfile b/Dockerfile index 445235d..4efa695 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,20 @@ -FROM node:20-alpine +FROM node:22-alpine3.19 AS base WORKDIR /usr/src/app +COPY . . -COPY package.json ./ -COPY yarn.lock ./ +FROM base AS prod-deps +RUN apk add --no-cache git +RUN yarn install --prod --frozen-lockfile +FROM base AS build RUN apk add --no-cache git RUN yarn install --frozen-lockfile - -COPY . . - RUN yarn build +FROM base +COPY --from=prod-deps /usr/src/app/node_modules /usr/src/app/node_modules +COPY --from=build /usr/src/app/dist /usr/src/app/dist + EXPOSE 3000 -CMD [ "node", "dist/main.js" ] \ No newline at end of file +CMD [ "node", "dist/main.js" ] diff --git a/package.json b/package.json index 9fdf23b..0c9d97f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "private": true, "license": "UNLICENSED", "scripts": { - "build": "prisma generate & nest build", + "build": "prisma generate && nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", "start:dev": "nest start --watch",