Skip to content

Commit 442ed08

Browse files
committed
refactor(cms): use pnpm in dockerfile
closed COD-364
1 parent 58abfda commit 442ed08

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

apps/cms/Dockerfile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ RUN apt-get update \
66
&& rm -rf /var/lib/apt/lists/*
77

88
FROM base AS deps
9+
10+
RUN npm install -g pnpm
11+
912
RUN apt-get update \
1013
&& apt-get install -y --no-install-recommends \
1114
git \
@@ -15,28 +18,25 @@ RUN apt-get update \
1518
libc6-dev \
1619
libvips-dev \
1720
&& rm -rf /var/lib/apt/lists/*
21+
1822
WORKDIR /app
1923

2024
COPY package.json ./
2125

22-
# Check the link regarding legacy-peer-deps
23-
# https://payloadcms.com/docs/getting-started/installation#1-install-the-relevant-packages
24-
# Keep optional deps so platform-specific native bindings (e.g. @swc/core) download prebuilts
25-
RUN npm i --legacy-peer-deps --no-audit --no-fund
26+
RUN pnpm install \
27+
&& pnpm store prune \
28+
&& STORE_PATH="$(pnpm store path --silent)" \
29+
&& rm -rf "$STORE_PATH"
2630

2731
# Copy the dependencies to builder stage.
2832
# Lock file is important for Nx to calculate a correct project graph.
2933
FROM base AS builder
3034

3135
WORKDIR /app
32-
COPY --from=deps /app/node_modules ./node_modules
33-
COPY --from=deps /app/package-lock.json ./package-lock.json
36+
COPY --from=deps /app/node_modules ./node_modules
37+
COPY --from=deps /app/pnpm-lock.yaml ./pnpm-lock.yaml
3438
COPY . .
3539

36-
# The lock file is hidden from the build process when included in the .gitignore file.
37-
# Since package-lock.json is needed when building the app, we'll remove it from .gitignore.
38-
RUN sed -i '/package-lock.json/d' .gitignore
39-
4040
# Build arguments for Next.js client-side environment variables
4141
# These are embedded in the JavaScript bundle during build
4242
ARG NEXT_PUBLIC_DEPLOY_ENV
@@ -69,9 +69,9 @@ FROM base AS runner
6969

7070
WORKDIR /app
7171

72-
ENV NODE_ENV production
72+
ENV NODE_ENV=production
7373
# Disable telemetry during runtime.
74-
ENV NEXT_TELEMETRY_DISABLED 1
74+
ENV NEXT_TELEMETRY_DISABLED=1
7575

7676
# Automatically leverage output traces to reduce image size
7777
# https://nextjs.org/docs/advanced-features/output-file-tracing
@@ -92,7 +92,7 @@ USER nextjs
9292

9393
EXPOSE 3000
9494

95-
ENV PORT 3000
95+
ENV PORT=3000
9696

9797
ENV HOSTNAME="0.0.0.0"
9898
CMD ["node", "apps/cms/server.js"]

apps/cms/Dockerfile.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tmp
2121
# Don't let host lock files detect wrong package manager in Dockerfile
2222
bun.lockb
2323
package-lock.json
24-
pnpm-lock.yaml
24+
#pnpm-lock.yaml
2525
yarn.lock
2626

2727
# Other apps

0 commit comments

Comments
 (0)