fix(docker): include pnpm-workspace and npmrc in builder context
The committed lockfile records overrides from pnpm-workspace.yaml. With the narrower manifest COPY, pnpm install --frozen-lockfile ran without the workspace file and failed with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH in CI. Copy package.json, pnpm-lock, pnpm-workspace and .npmrc together so the override config present in the lockfile is also supplied at install time.
This commit is contained in:
1 parent
bef1775dea
commit
3e0ba73d1c
2 files changed
+5
-2
No files matched your search
+4
-1
@@ -9,7 +9,10 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
|||||||
# install only needs to exist as a bootstrap and follows the active major.
|
# install only needs to exist as a bootstrap and follows the active major.
|
||||||
RUN apk add --no-cache git \
|
RUN apk add --no-cache git \
|
||||||
&& npm install -g pnpm@latest
|
&& npm install -g pnpm@latest
|
||||||
COPY package.json pnpm-lock.yaml* ./
|
# pnpm-workspace.yaml + .npmrc must be present too: the lockfile records the
|
||||||
|
# overrides from pnpm-workspace.yaml, and --frozen-lockfile rejects a build
|
||||||
|
# where the workspace config is absent (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH).
|
||||||
|
COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* .npmrc* ./
|
||||||
# pnpm fetch: download all deps into $PNPM_STORE first, so only the lockfile
|
# pnpm fetch: download all deps into $PNPM_STORE first, so only the lockfile
|
||||||
# change (not source changes) invalidates the network-heavy download layer.
|
# change (not source changes) invalidates the network-heavy download layer.
|
||||||
RUN pnpm fetch --ignore-scripts
|
RUN pnpm fetch --ignore-scripts
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const dockerfile = readFileSync("Dockerfile", "utf8");
|
|||||||
describe("Docker build cache", () => {
|
describe("Docker build cache", () => {
|
||||||
it("installs frozen dependencies before copying application source", () => {
|
it("installs frozen dependencies before copying application source", () => {
|
||||||
const manifests = dockerfile.indexOf(
|
const manifests = dockerfile.indexOf(
|
||||||
"COPY package.json pnpm-lock.yaml* ./",
|
"COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* .npmrc* ./",
|
||||||
);
|
);
|
||||||
const fetch = dockerfile.indexOf("pnpm fetch --ignore-scripts");
|
const fetch = dockerfile.indexOf("pnpm fetch --ignore-scripts");
|
||||||
const install = dockerfile.indexOf("pnpm install --frozen-lockfile");
|
const install = dockerfile.indexOf("pnpm install --frozen-lockfile");
|
||||||
|
|||||||
Reference in new issue
Block a user