Skip to content

Commit c1dc8db

Browse files
authored
RFC: Mount package.json for Corepack (#1512)
Our Dockerfiles currently run `corepack enable pnpm` without any versioning information: https://github.com/seek-oss/skuba/blob/bc2c69d3b85a6aba738c5d63d01f810a69b1a248/template/greeter/Dockerfile#L5 This may use a different version than is specified in package.json: https://github.com/seek-oss/skuba/blob/bc2c69d3b85a6aba738c5d63d01f810a69b1a248/template/greeter/package.json This can result in a subsequent `pnpm install --offline` to hang in CI on the following prompt: ```console Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-8.15.4.tgz. Do you want to continue? [Y/n] ```
1 parent bc2c69d commit c1dc8db

File tree

11 files changed

+28
-9
lines changed

11 files changed

+28
-9
lines changed

docs/deep-dives/pnpm.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ This migration guide assumes that your project was scaffolded with a **skuba** t
210210
```diff
211211
FROM --platform=arm64 node:20-alpine AS dev-deps
212212
213-
+ RUN corepack enable pnpm
213+
+ RUN --mount=type=bind,source=package.json,target=package.json \
214+
+ corepack enable pnpm
215+
214216
+ RUN pnpm config set store-dir /root/.pnpm-store
215217
216218
WORKDIR /workdir
@@ -279,7 +281,7 @@ This migration guide assumes that your project was scaffolded with a **skuba** t
279281
Your build pipeline may have previously output an ephemeral `.npmrc` with an auth token on the build agent.
280282
This needs to be output elsewhere to avoid overwriting the new pnpm configuration stored in `.npmrc`.
281283

282-
Swap out caching on `package.json` and `yarn.lock` for `.npmrc` and `pnpm-lock.yaml` at the same time.
284+
Swap out caching on `yarn.lock` for `.npmrc` and `pnpm-lock.yaml` at the same time.
283285

284286
```diff
285287
seek-oss/private-npm#v1.2.0:
@@ -290,9 +292,9 @@ This migration guide assumes that your project was scaffolded with a **skuba** t
290292
```diff
291293
seek-oss/docker-ecr-cache#v2.1.0:
292294
cache-on:
293-
- - package.json
294-
- - yarn.lock
295295
+ - .npmrc
296+
- package.json
297+
- - yarn.lock
296298
+ - pnpm-lock.yaml
297299
dockerfile: Dockerfile.dev-deps
298300
- secrets: id=npm,src=.npmrc

template/express-rest-api/.buildkite/pipeline.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ configs:
1212
seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
1313
cache-on:
1414
- .npmrc
15+
- package.json
1516
- pnpm-lock.yaml
1617
dockerfile: Dockerfile.dev-deps
1718
secrets: id=npm,src=tmp/.npmrc

template/express-rest-api/Dockerfile.dev-deps

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
44

5-
RUN corepack enable pnpm
5+
RUN --mount=type=bind,source=package.json,target=package.json \
6+
corepack enable pnpm
7+
68
RUN pnpm config set store-dir /root/.pnpm-store
79

810
WORKDIR /workdir

template/greeter/.buildkite/pipeline.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
agents:
22
queue: <%- prodBuildkiteQueueName %>
33

4+
# Allow conditional unblock + dodgy CI stuffs
5+
46
configs:
57
plugins:
68
- &aws-sm
@@ -12,6 +14,7 @@ configs:
1214
seek-oss/docker-ecr-cache#v2.1.1:
1315
cache-on:
1416
- .npmrc
17+
- package.json
1518
- pnpm-lock.yaml
1619
secrets: id=npm,src=tmp/.npmrc
1720

template/greeter/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
44

5-
RUN corepack enable pnpm
5+
RUN --mount=type=bind,source=package.json,target=package.json \
6+
corepack enable pnpm
7+
68
RUN pnpm config set store-dir /root/.pnpm-store
79

810
WORKDIR /workdir

template/koa-rest-api/.buildkite/pipeline.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ configs:
1212
seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
1313
cache-on:
1414
- .npmrc
15+
- package.json
1516
- pnpm-lock.yaml
1617
dockerfile: Dockerfile.dev-deps
1718
secrets: id=npm,src=tmp/.npmrc

template/koa-rest-api/Dockerfile.dev-deps

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
44

5-
RUN corepack enable pnpm
5+
RUN --mount=type=bind,source=package.json,target=package.json \
6+
corepack enable pnpm
7+
68
RUN pnpm config set store-dir /root/.pnpm-store
79

810
WORKDIR /workdir

template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ configs:
1212
seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
1313
cache-on:
1414
- .npmrc
15+
- package.json
1516
- pnpm-lock.yaml
1617
secrets: id=npm,src=tmp/.npmrc
1718

template/lambda-sqs-worker-cdk/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
55
# Needed for cdk
66
RUN apk add --no-cache bash
77

8-
RUN corepack enable pnpm
8+
RUN --mount=type=bind,source=package.json,target=package.json \
9+
corepack enable pnpm
10+
911
RUN pnpm config set store-dir /root/.pnpm-store
1012

1113
WORKDIR /workdir

template/lambda-sqs-worker/.buildkite/pipeline.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ configs:
1212
seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
1313
cache-on:
1414
- .npmrc
15+
- package.json
1516
- pnpm-lock.yaml
1617
secrets: id=npm,src=tmp/.npmrc
1718

template/lambda-sqs-worker/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
44

5-
RUN corepack enable pnpm
5+
RUN --mount=type=bind,source=package.json,target=package.json \
6+
corepack enable pnpm
7+
68
RUN pnpm config set store-dir /root/.pnpm-store
79

810
WORKDIR /workdir

0 commit comments

Comments
 (0)