Skip to content

Commit b67d942

Browse files
committed
πŸ› Fix yarn install using corepack on node v25
Also fail faster on builds by setting `-euo pipefail`
1 parent 8775750 commit b67d942

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

β€ŽDockerfileβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM python:trixie
22
LABEL org.opencontainers.image.authors="Nikolai R Kristiansen <nikolaik@gmail.com>"
33

4+
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
45
RUN groupadd --gid 1000 pn && useradd --uid 1000 --gid pn --shell /bin/bash --create-home pn
56
ENV POETRY_HOME=/usr/local
67

7-
# Install nodejs and yarn
88
RUN NODE_VERSION="$(curl -fsSL https://nodejs.org/dist/latest/SHASUMS256.txt | head -n1 | awk '{ print $2}' | awk -F - '{ print $2}')" \
99
ARCH= && dpkgArch="$(dpkg --print-architecture)" \
1010
&& case "${dpkgArch##*-}" in \
@@ -23,7 +23,7 @@ RUN NODE_VERSION="$(curl -fsSL https://nodejs.org/dist/latest/SHASUMS256.txt | h
2323
&& tar -xJf "node-$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
2424
&& rm "node-$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
2525
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
26-
RUN corepack enable yarn
26+
RUN npm install -g corepack && corepack enable yarn
2727
RUN \
2828
apt-get update && \
2929
apt-get upgrade -yqq && \

β€Žtemplates/alpine.Dockerfileβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# nodejs: {{ nodejs_canonical }}
44
FROM python:{{ python_image }} AS builder
55

6+
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
7+
68
# Install node prereqs, nodejs and yarn
79
# Ref: https://raw.githubusercontent.com/nodejs/docker-node/master/Dockerfile-alpine.template
810
# Ref: https://yarnpkg.com/en/docs/install
@@ -21,7 +23,7 @@ LABEL org.opencontainers.image.authors="Nikolai R Kristiansen <nikolaik@gmail.co
2123
RUN addgroup -g 1000 pn && adduser -u 1000 -G pn -s /bin/sh -D pn
2224
RUN apk add libstdc++
2325
COPY --from=builder /node-v{{ nodejs_canonical }}-linux-x64-musl /usr/local
24-
RUN corepack enable yarn
26+
RUN npm install -g corepack && corepack enable yarn
2527
RUN pip install -U pip pipenv uv
2628

2729
# Poetry

β€Žtemplates/debian.Dockerfileβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
FROM python:{{ python_image }}
55
LABEL org.opencontainers.image.authors="Nikolai R Kristiansen <nikolaik@gmail.com>"
66

7+
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
78
RUN groupadd --gid 1000 pn && useradd --uid 1000 --gid pn --shell /bin/bash --create-home pn
89
ENV POETRY_HOME=/usr/local
910

@@ -29,7 +30,7 @@ RUN NODE_VERSION="v{{ nodejs_canonical }}" \
2930
&& tar -xJf "node-$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
3031
&& rm "node-$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
3132
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
32-
RUN corepack enable yarn
33+
RUN npm install -g corepack && corepack enable yarn
3334

3435
RUN pip install -U pip pipenv uv && \
3536
curl -fsSL --compressed https://install.python-poetry.org | python -

0 commit comments

Comments
Β (0)