skip to Main Content

I’m having trouble composing a docker container that contains SQLite3 as one of its services on my M1 Macbook. I have seen this problem at https://github.com/docker/getting-started/issues/222#issuecomment-978730011
and references to it at https://docs.docker.com/desktop/mac/apple-silicon/ but I am not sure how to reproduce their solution for my situation.

The error I am getting is below

> [webpersonal.azurecr.io/jb-api:latest builder 4/6] RUN yarn install --frozen-lockfile:
#23 0.349 yarn install v1.22.17
#23 0.400 [1/4] Resolving packages...
#23 0.512 [2/4] Fetching packages...
#23 250.6 [3/4] Linking dependencies...
#23 254.5 [4/4] Building fresh packages...
#23 257.5 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
#23 257.5 error /app/node_modules/sqlite3: Command failed.
#23 257.5 Exit code: 1
#23 257.5 Command: node-pre-gyp install --fallback-to-build
#23 257.5 Arguments: 
#23 257.5 Directory: /app/node_modules/sqlite3
#23 257.5 Output:
#23 257.5 node-pre-gyp info it worked if it ends with ok
#23 257.5 node-pre-gyp info using [email protected]
#23 257.5 node-pre-gyp info using [email protected] | linux | arm64
#23 257.5 node-pre-gyp WARN Using request for node-pre-gyp https download 
#23 257.5 node-pre-gyp info check checked for "/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64/node_sqlite3.node" (not found)
#23 257.5 node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-linux-arm64.tar.gz
#23 257.5 node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-linux-arm64.tar.gz
#23 257.5 node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-linux-arm64.tar.gz 
#23 257.5 node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v102 ABI, glibc) (falling back to source compile with node-gyp) 
#23 257.5 node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-linux-arm64.tar.gz 
#23 257.5 gyp info it worked if it ends with ok
#23 257.5 gyp info using [email protected]
#23 257.5 gyp info using [email protected] | linux | arm64
#23 257.5 gyp info ok 
#23 257.5 gyp info it worked if it ends with ok
#23 257.5 gyp info using [email protected]
#23 257.5 gyp info using [email protected] | linux | arm64
#23 257.5 gyp ERR! configure error 
#23 257.5 gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
#23 257.5 gyp ERR! stack     at PythonFinder.failNoPython (/app/node_modules/node-gyp/lib/configure.js:484:19)
#23 257.5 gyp ERR! stack     at PythonFinder.<anonymous> (/app/node_modules/node-gyp/lib/configure.js:406:16)
#23 257.5 gyp ERR! stack     at F (/app/node_modules/which/which.js:68:16)
#23 257.5 gyp ERR! stack     at E (/app/node_modules/which/which.js:80:29)
#23 257.5 gyp ERR! stack     at /app/node_modules/which/which.js:89:16
#23 257.5 gyp ERR! stack     at /app/node_modules/isexe/index.js:42:5
#23 257.5 gyp ERR! stack     at /app/node_modules/isexe/mode.js:8:5
#23 257.5 gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
#23 257.5 gyp ERR! System Linux 5.10.76-linuxkit
#23 257.5 gyp ERR! command "/usr/local/bin/node" "/app/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
#23 257.5 gyp ERR! cwd /app/node_modules/sqlite3
#23 257.5 gyp ERR! node -v v17.5.0
#23 257.5 gyp ERR! node-gyp -v v3.8.0
#23 257.5 gyp ERR! not ok 
#23 257.5 node-pre-gyp ERR! build error 
#23 257.5 node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /app/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
#23 257.5 node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/app/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
#23 257.5 node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:526:28)
#23 257.5 node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1090:16)
#23 257.5 node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
#23 257.5 node-pre-gyp ERR! System Linux 5.10.76-linuxkit
#23 257.5 node-pre-gyp ERR! command "/usr/local/bin/node" "/app/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
#23 257.5 node-pre-gyp ERR! cwd /app/node_modules/sqlite3
#23 257.5 node-pre-gyp ERR! node -v v17.5.0
#23 257.5 node-pre-gyp ERR! node-pre-gyp -v v0.11.0
#23 257.5 node-pre-gyp ERR! not ok 
#23 257.5 Failed to execute '/usr/local/bin/node /app/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c yarn install --frozen-lockfile]: exit code: 1

The docker-compose file I’m using is below. I have removed the values corresponding to the various MYSQL keys.

version: '3.3'
services:
  api:
    build:
      dockerfile: Dockerfile
      context: ./backend
    image: webpersonal.azurecr.io/jb-api:latest
    ports:
      - "8080:8080"
    expose:
      - 8080
    environment:
      - NODE_ENV=development
      - SERVER_PORT=8080
      - MYSQL_RANDOM_ROOT_PASSWORD=true
      - MYSQL_HOST=db
      - MYSQL_PORT=3306
      - MYSQL_USER=
      - MYSQL_PASSWORD=
      - MYSQL_DATABASE=
      - RESTRICTED_LOGINS=false
  frontend:
    build:
      context: ./frontend
    image: webpersonal.azurecr.io/jb-frontend:latest
    ports:
      - "8081:80"
    expose:
      - 8081
  db:
    image: mariadb:latest
    ports:
      - "3306:3306"
    expose:
      - 3306
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=true
      - MYSQL_HOST=db
      - MYSQL_PORT=3306
      - MYSQL_USER=
      - MYSQL_PASSWORD=
      - MYSQL_DATABASE=
  test:
    build:
      dockerfile: Dockerfile.test
      context: ./backend

The Dockerfile for the backend where the error is occurring during the docker-compose up process is below

FROM node:latest as builder

WORKDIR /app
COPY ["./package.json", "./yarn.lock", "/app/"]
RUN yarn install --frozen-lockfile
COPY "./" "/app/"
RUN yarn build

FROM node:slim
WORKDIR /app
COPY --from=builder "/app/dist/" "/app/dist/"
COPY --from=builder "/app/node_modules/" "/app/node_modules/"
COPY --from=builder "/app/package.json" "/app/package.json"

EXPOSE 8080

CMD sleep 10 && node ./dist/index.js

2

Answers


  1. The following line hints that there is not python executable or it cannot be found:

    stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
    

    To chase down the issue, you can run the image standalone

    $ docker run --rm -ti node:latest /bin/bash
    root@a0382c43b2fd:/# which python
    root@a0382c43b2fd:/# apt-get update
    Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
    Get:2 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
    Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
    Get:4 http://security.debian.org/debian-security bullseye-security/main arm64 Packages [117 kB]
    Get:5 http://deb.debian.org/debian bullseye/main arm64 Packages [8070 kB]
    Get:6 http://deb.debian.org/debian bullseye-updates/main arm64 Packages [2596 B]
    Fetched 8389 kB in 1s (6142 kB/s)
    Reading package lists... Done
    root@a0382c43b2fd:/# apt-get install python -y
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Note, selecting 'python-is-python2' instead of 'python'
    The following additional packages will be installed:
      libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib mailcap mime-support python2 python2-minimal python2.7 python2.7-minimal
    Suggested packages:
      python2-doc python-tk python2.7-doc binfmt-support
    The following NEW packages will be installed:
      libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib mailcap mime-support python-is-python2 python2 python2-minimal python2.7 python2.7-minimal
    0 upgraded, 10 newly installed, 0 to remove and 2 not upgraded.
    Need to get 3981 kB of archives.
    After this operation, 16.2 MB of additional disk space will be used.
    Get:1 http://deb.debian.org/debian bullseye/main arm64 libpython2.7-minimal arm64 2.7.18-8 [396 kB]
    Get:2 http://deb.debian.org/debian bullseye/main arm64 python2.7-minimal arm64 2.7.18-8 [1303 kB]
    Get:3 http://deb.debian.org/debian bullseye/main arm64 python2-minimal arm64 2.7.18-3 [34.2 kB]
    Get:4 http://deb.debian.org/debian bullseye/main arm64 mailcap all 3.69 [31.7 kB]
    Get:5 http://deb.debian.org/debian bullseye/main arm64 mime-support all 3.66 [10.9 kB]
    Get:6 http://deb.debian.org/debian bullseye/main arm64 libpython2.7-stdlib arm64 2.7.18-8 [1846 kB]
    Get:7 http://deb.debian.org/debian bullseye/main arm64 python2.7 arm64 2.7.18-8 [311 kB]
    Get:8 http://deb.debian.org/debian bullseye/main arm64 libpython2-stdlib arm64 2.7.18-3 [21.2 kB]
    Get:9 http://deb.debian.org/debian bullseye/main arm64 python2 arm64 2.7.18-3 [24.5 kB]
    Get:10 http://deb.debian.org/debian bullseye/main arm64 python-is-python2 all 2.7.18-9 [2940 B]
    Fetched 3981 kB in 0s (11.6 MB/s)
    debconf: delaying package configuration, since apt-utils is not installed
    Selecting previously unselected package libpython2.7-minimal:arm64.
    (Reading database ... 22732 files and directories currently installed.)
    Preparing to unpack .../0-libpython2.7-minimal_2.7.18-8_arm64.deb ...
    Unpacking libpython2.7-minimal:arm64 (2.7.18-8) ...
    Selecting previously unselected package python2.7-minimal.
    Preparing to unpack .../1-python2.7-minimal_2.7.18-8_arm64.deb ...
    Unpacking python2.7-minimal (2.7.18-8) ...
    Selecting previously unselected package python2-minimal.
    Preparing to unpack .../2-python2-minimal_2.7.18-3_arm64.deb ...
    Unpacking python2-minimal (2.7.18-3) ...
    Selecting previously unselected package mailcap.
    Preparing to unpack .../3-mailcap_3.69_all.deb ...
    Unpacking mailcap (3.69) ...
    Selecting previously unselected package mime-support.
    Preparing to unpack .../4-mime-support_3.66_all.deb ...
    Unpacking mime-support (3.66) ...
    Selecting previously unselected package libpython2.7-stdlib:arm64.
    Preparing to unpack .../5-libpython2.7-stdlib_2.7.18-8_arm64.deb ...
    Unpacking libpython2.7-stdlib:arm64 (2.7.18-8) ...
    Selecting previously unselected package python2.7.
    Preparing to unpack .../6-python2.7_2.7.18-8_arm64.deb ...
    Unpacking python2.7 (2.7.18-8) ...
    Selecting previously unselected package libpython2-stdlib:arm64.
    Preparing to unpack .../7-libpython2-stdlib_2.7.18-3_arm64.deb ...
    Unpacking libpython2-stdlib:arm64 (2.7.18-3) ...
    Setting up libpython2.7-minimal:arm64 (2.7.18-8) ...
    Setting up python2.7-minimal (2.7.18-8) ...
    Linking and byte-compiling packages for runtime python2.7...
    Setting up python2-minimal (2.7.18-3) ...
    Selecting previously unselected package python2.
    (Reading database ... 23502 files and directories currently installed.)
    Preparing to unpack .../python2_2.7.18-3_arm64.deb ...
    Unpacking python2 (2.7.18-3) ...
    Selecting previously unselected package python-is-python2.
    Preparing to unpack .../python-is-python2_2.7.18-9_all.deb ...
    Unpacking python-is-python2 (2.7.18-9) ...
    Setting up mailcap (3.69) ...
    Setting up mime-support (3.66) ...
    Setting up libpython2.7-stdlib:arm64 (2.7.18-8) ...
    Setting up python2.7 (2.7.18-8) ...
    Setting up libpython2-stdlib:arm64 (2.7.18-3) ...
    Setting up python2 (2.7.18-3) ...
    Setting up python-is-python2 (2.7.18-9) ...
    root@a0382c43b2fd:/# which python
    /usr/bin/python
    

    You can now incorporate this into your dockerfile and then it looks something like

    FROM node:latest as builder
    
    WORKDIR /app
    COPY ["./package.json", "./yarn.lock", "/app/"]
    RUN apt-get update &&
      apt-get install python -y
    RUN yarn install --frozen-lockfile
    COPY "./" "/app/"
    RUN yarn build
    
    FROM node:slim
    WORKDIR /app
    COPY --from=builder "/app/dist/" "/app/dist/"
    COPY --from=builder "/app/node_modules/" "/app/node_modules/"
    COPY --from=builder "/app/package.json" "/app/package.json"
    
    EXPOSE 8080
    
    CMD sleep 10 && node ./dist/index.js
    
    Login or Signup to reply.
  2. Add this line to your dockerfile.
    RUN apk add --update python2 make g++

    FROM node:12-alpine 
    
    RUN apk add --update python2 make g++  
    
    WORKDIR /usr/src/app
    
    ...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search