docker-node: [buildx/arm64] yarn and npm not able to download packages from internet
Hi there,
thanks for your awesome work with this project. I am experiencing issues using buildx for the arm64 arch. Everything is running smooth until yarn or npm is trying to download packages over the network.
This is an snipped from build-log running on GitHub actions while using yarn:
#22 [linux/arm64 build-deps 5/6] RUN yarn --production
#22 176.3 info There appears to be trouble with your network connection. Retrying...
#22 195.3 error An unexpected error occurred: "https://registry.yarnpkg.com/date-fns/-/date-fns-2.16.1.tgz: ESOCKETTIMEDOUT".
Running the same buildx build locally the output is a bit more concise:
=> [linux/arm64 build-deps 5/6] RUN yarn --production
=> => # Unknown QEMU_IFLA_INFO_KIND ipip
=> => # Unknown QEMU_IFLA_INFO_KIND ip6tnl
=> => # yarn install v1.22.5
=> => # Unknown QEMU_IFLA_INFO_KIND ipip
=> => # Unknown QEMU_IFLA_INFO_KIND ip6tnl
=> => # [1/4] Resolving packages...
=> => # [2/4] Fetching packages...
=> => # Unknown QEMU_IFLA_INFO_KIND ipip
=> => # Unknown QEMU_IFLA_INFO_KIND ip6tnl
=> => # info There appears to be trouble with your network connection. Retrying...
The command used to start the build:
docker buildx build --platform linux/amd64,linux/arm64 -t myrepo/myproject:latest --push client/
My Dockerfile looks like this:
(Note that I do not copy node_modules into build context. The files to copy are managed using a .dockerignore
file.)
# Stage 1 - the build process
FROM node:latest as build-deps
WORKDIR /usr/src/app
ARG REACT_APP_GRAPH_URL
ENV REACT_APP_GRAPH_URL=$REACT_APP_GRAPH_URL
COPY . ./
COPY .env.example .env
RUN yarn --production
RUN yarn build
# Stage 2 - the deployment
FROM nginx:latest
COPY --from=build-deps /usr/src/app/build /usr/share/nginx/html
COPY docker/default /etc/nginx/conf.d/default.conf
Workaround
As a workaround I currently using a .yarnrc to create an offline cache. I copy a it into the build context and install it with the yarn --offline
option. That works for now, but I do not like it very much. https://classic.yarnpkg.com/blog/2016/11/24/offline-mirror/
thank you again and best regards
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 45
- Comments: 35 (1 by maintainers)
Links to this issue
Commits related to this issue
- Adjust yarn network timeout https://github.com/nodejs/docker-node/issues/1335 — committed to electerious/Ackee by electerious 3 years ago
- ci: increase yarn network timeout See https://github.com/docker/build-push-action/issues/471 https://github.com/nodejs/docker-node/issues/1335 — committed to nhost/hasura-auth by plmercereau 2 years ago
- Chore: disable arm64 docker build https://github.com/nodejs/docker-node/issues/1335 — committed to interlay/interbtc-squid by ns212 2 years ago
- build: increase network timeout for frontend build for arm64 build (see nodejs/docker-node#1335) — committed to webrecorder/browsertrix by ikreymer 2 years ago
- build: increase network timeout for yarn for frontend build for arm64 build (#401) - build: increase network timeout for frontend build for arm64 build (see nodejs/docker-node#1335) - also bump micr... — committed to webrecorder/browsertrix by ikreymer 2 years ago
- Adjust yarn network timeout https://github.com/nodejs/docker-node/issues/1335 — committed to keeneyetact/Ackee-GAnalytic by keeneyetact 3 years ago
- use alternative parameters for cache, workaround for https://github.com/nodejs/docker-node/issues/1335 — committed to localagi/AI-pipeline by invalid-email-address a year ago
- ci: Allow multiplatform build targeting specific ARM architectures There is an issues with Node v19+ and arm based images. It is described in https://github.com/nodejs/docker-node/issues/1794 and htt... — committed to kubeshop/monokle-admission-controller by f1ames 8 months ago
- ci: Allow multiplatform build targeting specific ARM architectures There is an issues with Node v19+ and arm based images. It is described in https://github.com/nodejs/docker-node/issues/1794 and htt... — committed to kubeshop/monokle-admission-controller by f1ames 8 months ago
- [feat] build multiplatform docker images (`amd64` + `arm64`) see also: https://github.com/nodejs/docker-node/issues/1335 — committed to flashbots/mev-flood by 0x416e746f6e 5 months ago
Meet the same issue on Github Actions Ci:
Build and push
linux/amd64
image cost about 2-3 mins, but buildlinux/arm64
cost about more than half an hour and always in theyarn install
… state.I think this is fairly reproducible. On my ubuntu machines, any
Dockerfile
that includesRUN npm ....
will fail in this same way when either targeting anarm64
image, or runningdocker buildx build
when the targets include anarm64
target.I am not able to reproduce however on my macbooks.
Hi @LaurentGoderre ,
As I wrote, the same holds true for running in GitHub Action environments. I already had this idea, so I verified the issue by running the build on other platforms. Also, in every environment amd64 builds just fine.
What do you think I can further do, to help with this issue?
Thanks and best regards
Let me guess – you’re not building on an actual arm64 runner node which means the arm64 build is generated using QEMU. Emulation is slow, therefore there’s much higher risk of running into timeouts.
It may be still possible there’s an additional problem with the network connection which may be worth debugging (I do see
ESOCKETTIMEDOUT
in the logs) but I’m not sure if this is related todocker-node
in any way.While this seems plausible, I think it’s the common case that projects will build against an emulated environment. Would it not be an improvement to
docker-node
to perhaps update documentation in some way to call this out?I had the same problem, but then I found this
docker run --privileged --rm tonistiigi/binfmt --install all
in the official documentation, which solved my problem. Further explanation will be found in the docs itself.
Config that worked for me to build the arm64 with yarn on GitHub actions:
Add this to your Dockerfile before
RUN yarn install
:set network-timeout 300000
People on node 20 with npm 10 could try downgrading npm to v9 because v10 has a known bug where it opens an excessive amount of network connections, see https://github.com/npm/cli/issues/7072.
@mohsenasm I agree with you. Look’s like this effects
node:20
(lts). I have downgraded my dockerfile tonode:18-alpine3.19
andyarn install
now works again.Same here. Less than a minute locally vs. 8 minutes on average running in a Docker build step on GitHub Actions. I confirm we are building an
arm64
image with Dockerbuildx
official action.Also, no way to get it working without using
--network-timeout 100000
.It also stuck in
#14 [dependencies 2/5] RUN yarn config set network-timeout 300000
fornode:20-alpine
andlinux/arm/v7
. Super weird!I tried all approaches, even building on an arm64 machine without buildx or QEMU. However, I kept receiving a timeout error.
i’m stuck at yarn install too…
not possible to run on github workflows
edit: Without anything else, this seems to fix it on our side https://github.com/JamesonRGrieve/Agent-LLM-Frontend/pull/14
@LiterallyWar This error can be reproduced with these docker files & GH workflows as well.
https://github.com/frappe/frappe_docker https://github.com/frappe/frappe_docker/actions/runs/4401435320/jobs/7707642818
@LiterallyWar I was just able to reproduce my Error:
After running
docker run --privileged --rm tonistiigi/binfmt --install all
it runs perfectly.I’m using
docker buildx
for building the images and takes around 2 minutes including publishing the images. I don’t usedocker/setup-qemu-action@v2
but I don’t use GitHub Actions.Furthermore, I run it locally, and I’m using Colima as the daemon.
@PeterDaveHello I noticed you added the yarn label to this issue. I also checked this using npm with the exact same behavior as yarn.
Currently I am trying to run some network diagnostic inside the container. If I stumble upon something useful, I will let you know.
best regards