Home > Back-end >  Docker Alpine: unable to select packages: python (no such package) while building image for ARM
Docker Alpine: unable to select packages: python (no such package) while building image for ARM

Time:11-10

I have Node.js app that uses SQLite database. To use it on ARM architecture, I need to build sqlite3 binaries so I need some packages while building Docker image.

Here is my Dockerfile:

FROM node:14-alpine as builder

WORKDIR /app

COPY package*.json ./

RUN apk update \
    && apk --no-cache --virtual build-dependencies add python make g   \
    && npm install --production

COPY . .    

RUN mkdir -p ./public ./data \
    && cd ./client \
    && npm install --production \
    && npm run build \
    && cd .. \
    && mv ./client/build/* ./public \
    && rm -rf ./client \
    && apk del build-dependencies

FROM node:14-alpine

COPY --from=builder /app /app

WORKDIR /app

EXPOSE 5005

ENV NODE_ENV=production

CMD ["node", "server.js"]

I've been using it for 6 months and it was working fine but now it throws this error:

> [linux/amd64 builder 4/6] RUN apk update && apk --no-cache --virtual build-dependencies add python make g   && npm install --production:
#10 0.166 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
#10 0.503 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
#10 1.141 v3.14.2-123-g010734651f [https://dl-cdn.alpinelinux.org/alpine/v3.14/main]
#10 1.141 v3.14.2-120-g90167408c8 [https://dl-cdn.alpinelinux.org/alpine/v3.14/community]
#10 1.141 OK: 14943 distinct packages available      
#10 1.216 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
#10 1.476 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
#10 1.936 ERROR: unable to select packages:
#10 1.989   python (no such package):
#10 1.989     required by: build-dependencies-20211108.132318[python]
------
Dockerfile.multiarch:7
--------------------
   6 |
   7 | >>> RUN apk update \
   8 | >>>     && apk --no-cache --virtual build-dependencies add python make g   \
   9 | >>>     && npm install --production
  10 |
--------------------
error: failed to solve: process "/bin/sh -c apk update     && apk --no-cache --virtual build-dependencies 
add python make g       && npm install --production" 
did not complete successfully: exit code: 2

I tried to specific python version like so: ... add python3 make .... It passes this step but I'm getting this error while building sqlite3 binaries:

#20 392.8 make: Entering directory '/app/node_modules/sqlite3/build'
#20 392.8   CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
#20 393.6   AR(target) Release/obj.target/../node-addon-api/nothing.a
#20 393.8   COPY Release/nothing.a
#20 394.0   ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c
#20 394.1 /bin/sh: python: not found
#20 394.1 make: *** [deps/action_before_build.target.mk:13: Release/obj/gen/sqlite-autoconf-3340000/sqlite3.c] Error 127
#20 394.1 make: Leaving directory '/app/node_modules/sqlite3/build'

CodePudding user response:

We hit the same error and in our case explicitly targeting python3 seems to fix it. I asked on IRC, did not find out yet why python is not working anymore, but was told that python2 still provides /usr/bin/python. So maybe you actually need python2?

CodePudding user response:

RUN apk add --no-cache --virtual .gyp python3 make g  
  • Related