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
The following line hints that there is not python executable or it cannot be found:
To chase down the issue, you can run the image standalone
You can now incorporate this into your dockerfile and then it looks something like
Add this line to your dockerfile.
RUN apk add --update python2 make g++