`yarn` not found in `node:alpine`
I'm using the node:alpine image in a gitlab-ci build.
Since a few minutes ago I get the following error in gitlab-ci:
$ yarn config set cache-folder .yarn
/bin/sh: eval: line 50: yarn: not found
ERROR: Job failed: exit code 127
My .gitlab-ci.yaml:
build:
image: node:alpine
stage: build
script:
- yarn config set cache-folder .yarn
- yarn
- yarn build
I think it's a little bit awkward that changes will be commited to existing tags other than "rc", "nightly" or similar. In my opinion a version like 9.8.0 should never ever be changed. When changes have to be made it's 9.8.1. Many many ci pipelines will be broken today with many many hours of work of devops to find the solution.
A version label should be cast in stone, particularly for something as widely used as this. Lots of wasted hours and heads scratched over this today.
Finding the root of the issue was not that hard... 😅
However I agree that the tagged versions that represent a full semver specifier should never be modified
@n1ru4l depends on how you specify the semver for the node images:
should it be inline with the nodejs version? IMHO: yes
but then you might also want to have security patches for the underlying OS for this nodejs version to somehow show up (automatically)?
I would be very interested in reading a blog post on how this mistake happened and what steps you've taken to ensure that it won't happen again.
@Kosta-Github I think it would be enough to match corresponding minor version of node
@davidblurton Here's a draft: https://github.com/nodejs/docker-node/pull/650
@Kosta-Github I forgot about the security patches 😅
@davidblurton As I see it there were few issues:
- We didn't have a basic test of yarn which would have caught this early (fixed in #650)
- We should not have immediately pushed the changes to the docker hub. Instead, the changes to how yarn is installed/linked should have been grouped with a Node.js (and therefor docker tag) update.
Also note that the tag is updated automatically by docker hub to account for security fixes in the underlying OS, so the only way to truly lock it down is to use the id of the image, not the tag
A docker image is an artifact of its own, and thus needs it own version. The image version may not need to be a full semver though, only a build increment. node:alpine-8.6.0_16 for the 17th release of node-alpine-8.6.0 might be sufficient. node:alpine-8-6 and node:alpine-8 might still be mutable "tags".
As @SimenB already written, image id is immutable identifier of the docker image, i. e. instead of
$ docker pull node:9.8.0-alpine
9.8.0-alpine: Pulling from library/node
Digest: sha256:1fbcd77d0eb2af765d24ae4758b5a94b0d55c6002a15a4431d55795a449ebd3d
Status: Image is up to date for node:9.8.0-alpine
you should use
$ docker pull node@sha256:1fbcd77d0eb2af765d24ae4758b5a94b0d55c6002a15a4431d55795a449ebd3d
There's a good reason for tags not being immutable. One of the main benefit of Docker is that you inherit security fixes to underlying images. Sure there's a chance that a change to the base image might break a build but it's a trade-off that I personally gladly take to get the security benefits.
Happening to our builds too...!
@ojab as I wrote in my first comment, I am perfectly aware how to lock down a version. However, I find the use of “tag” misleading. In version control systems, a tag usually points to a given revision or commit (possibly on a specific branch). When a “tag” is updated, it is more like a VCS branch. The main problem with using the digest notation is that you don’t immediately see which tag it originated from.
Other repositories as Maven, NPM, Yum, etc., contain versioned artifacts. I do not see why Docker should not.
@LaurentGoderre There exist syntaxes for specifying that you want the latest version (at some level) for semver. But providing people the possibility to easily lock down the version would be nice. You never know when even a security patch breaks your production system.
We are staying consistent with the other docker official images. Maybe there will be a solution to this issue in the future (in the form of a lockfile or something)
Hey guys,
thanks for the quick fix <3
That being said we continue having the problem when building our images :( Is there something peculiar that should be done to get back to work properly?
You need to wait for the image to be published. It's currently being built
@LaurentGoderre consistency is a good thing. :) Repeatable builds provides even better consistency. My comment is not limited to the node image. Where is the right place to raise this issue?