I need to include python2 in my Dockerfile for a Vue app in order to build a dependency node-sass@4.14.1 (defined in package.json). The following works fine:
FROM node:16.15.0-alpine as builder
RUN apk add --no-cache python2 make g++
...
ADD app/package.json .
RUN CXXFLAGS="--std=c++14" npm install
But this node image is using alpine 3.15, which has a critical vulnerability in zlib that I would like to remove, so I want to use a newer alpine version. But using e.g. node:16.15.1-alpine (which uses alpine-3.16) then apk add fails, since python2 is no longer included in that image.
I tried to set the PYTHON env variable and use python3 instead, but then the build of node-gyp@3.8.0 (used by node-sass@4.14.1) fails with SyntaxError: Missing parentheses in call to 'print', so for this version, python2 seems to be needed to build.
In package.json, my devDependencies are:
"devDependencies": {
...
"node-sass": "^4.14.1",
"sass-loader": "^7.0.1"
(Yes, I realize that the node-sass version is old (as is python2), and also that node-sass is deprecated, but trying to use a newer version of this package lead to other issues, so I first wanted to try to just make the build work with existing versions, but a newer alpine.)
How can I add python2 when using node:16.15.1-alpine as base image?