From 3b10abfa3ea8490bb4e87a704c545cb508c53da7 Mon Sep 17 00:00:00 2001 From: na2na-p Date: Mon, 27 May 2024 22:55:03 +0900 Subject: [PATCH] =?UTF-8?q?node=5Fmodules=E3=81=AE=E4=B8=AD=E8=BA=AB?= =?UTF-8?q?=E3=81=8D=E3=82=8C=E3=81=84=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/docker/Dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/infra/docker/Dockerfile b/infra/docker/Dockerfile index a3feda49..98ebcf90 100644 --- a/infra/docker/Dockerfile +++ b/infra/docker/Dockerfile @@ -1,6 +1,6 @@ ARG NODE_VERSION=20.13.1-bookworm -FROM node:${NODE_VERSION} AS builder +FROM node:${NODE_VERSION} AS base RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ @@ -16,8 +16,11 @@ WORKDIR /jetdisc COPY --link ["pnpm-lock.yaml", "package.json", "./"] -RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \ - pnpm i --frozen-lockfile --aggregate-output +FROM base AS prod-deps +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile + +FROM base AS builder +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile COPY --link . ./ @@ -43,10 +46,11 @@ RUN apt-get update \ USER jetdisc WORKDIR /jetdisc -COPY --chown=jetdisc:jetdisc --from=builder /jetdisc/node_modules ./node_modules +COPY --chown=jetdisc:jetdisc --from=prod-deps /jetdisc/node_modules ./node_modules COPY --chown=jetdisc:jetdisc --from=builder /jetdisc/built ./built COPY --chown=jetdisc:jetdisc . ./ ENV NODE_ENV=production + ENTRYPOINT ["/usr/bin/tini", "--"] CMD ["pnpm", "run", "start"]