diff --git a/Dockerfile.auth b/Dockerfile.auth index 1095cb2..7d79aa8 100644 --- a/Dockerfile.auth +++ b/Dockerfile.auth @@ -3,12 +3,20 @@ FROM node:22-alpine AS builder WORKDIR /auth-builder -COPY ./package.json ./ +# Copy package manifests first for better layer caching +COPY ./package.json ./package-lock.json ./ +COPY ./apps/auth/package.json ./apps/auth/ +COPY ./shared/database/package.json ./shared/database/ +COPY ./shared/authentication/package.json ./shared/authentication/ + +RUN npm ci + +# Copy source code and build (this layer invalidates on code changes) COPY ./tsconfig.base.json ./ COPY ./shared ./shared COPY ./apps/auth ./apps/auth -RUN npm install && npm run build --workspace=@wxyc/database --workspace=shared/** --workspace=@wxyc/auth-service +RUN npm run build --workspace=@wxyc/database --workspace=shared/** --workspace=@wxyc/auth-service #Production stage FROM node:22-alpine AS prod diff --git a/Dockerfile.backend b/Dockerfile.backend index a31baec..57e5e8a 100644 --- a/Dockerfile.backend +++ b/Dockerfile.backend @@ -3,12 +3,20 @@ FROM node:22-alpine AS builder WORKDIR /builder -COPY ./package.json ./ +# Copy package manifests first for better layer caching +COPY ./package.json ./package-lock.json ./ +COPY ./apps/backend/package.json ./apps/backend/ +COPY ./shared/database/package.json ./shared/database/ +COPY ./shared/authentication/package.json ./shared/authentication/ + +RUN npm ci + +# Copy source code and build (this layer invalidates on code changes) COPY ./tsconfig.base.json ./ COPY ./shared ./shared COPY ./apps/backend ./apps/backend -RUN npm install && npm run build --workspace=@wxyc/database --workspace=shared/** --workspace=@wxyc/backend +RUN npm run build --workspace=@wxyc/database --workspace=shared/** --workspace=@wxyc/backend #Production stage FROM node:22-alpine AS prod