Installing node binary package from https://nodejs.org/en/download/
I use Docker on my x86_64 Ubuntu Workstation and Macbook Pro M1 aarm64 so Dockerfiles need to be multi-arch
This Dockerfile snippet detects the architecture we are running in and sets the correct DISTRO environment variable so we don't have to hard code it.
1 2 3 4 5 6 7 8 9 10 11 12 | # hard code VERSION # ARG doesn't persist into the future container like ENV does ARG VERSION=v16.14.0 RUN apArch=$(arch); \ case "$apArch" in \ x86_64) export DISTRO= 'linux-x64' ;; \ aarch64) export DISTRO= 'linux-arm64' ;;\ esac ;\ cd /build && \ wget https: //nodejs .org /dist/v16 .14.0 /node- ${VERSION}-${DISTRO}. tar .xz && \ tar -xvf node-${VERSION}-${DISTRO}. tar .xz --strip-components=1 -C /usr/local |
npm builds fail on v17+ of node
Note: For the moment I am staying with node v16 LTS because when you run v17 you have to use --openssl-legacy-provider
in your package.json build / run args to work around deprecated SSL
1 2 3 4 5 6 | "scripts" : { "start" : "react-scripts --openssl-legacy-provider start" , "build" : "react-scripts --openssl-legacy-provider build && rm -rf ../../../webroot/shipment-app && cp -rv build ../../../webroot/shipment-app" , "test" : "react-scripts test" , "eject" : "react-scripts eject" }, |
Very useful blog post about ENV, ARG etc here https://vsupalov.com/docker-build-pass-environment-variables/
0 Comments