dockerfile-yarn-install-without-immutable-lockfile
Detects Node Dockerfiles that run Yarn dependency installation without a lockfile-immutable flag while yarn.lock is available in the Docker build context.
This rule looks for:
- a Docker build discovered from GitHub Actions
yarn.lockin the build contextRUN yarn,RUN yarn install, orRUN yarn add- no
--immutableor--frozen-lockfileflag on that Dockerfile instruction - global installs such as
yarn global addoryarn add -gare out of scope
Why it matters:
- Docker dependency installs should be tied to the committed lockfile.
- Modern Yarn uses
--immutableto fail when the lockfile would be modified. - Yarn Classic uses
--frozen-lockfilefor the same CI-oriented behavior. yarn addmutates dependencies and should not be part of a clean Docker image build.
What to do:
- Use
yarn install --immutablefor modern Yarn. - Use
yarn install --frozen-lockfilefor Yarn Classic. - Avoid
yarn addduring Docker image builds.
This rule intentionally focuses on lockfile immutability. It does not require a Zero-Installs cache layout.