Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build error in git action with linux/arm64 #469

Closed
c121914yu opened this issue May 8, 2024 · 2 comments
Closed

Docker build error in git action with linux/arm64 #469

c121914yu opened this issue May 8, 2024 · 2 comments

Comments

@c121914yu
Copy link

action:

jobs:
  build-fastgpt-images:
    runs-on: ubuntu-20.04
    if: github.repository != 'labring/FastGPT'
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
        with:
          driver-opts: network=host
      - name: Cache Docker layers
        uses: actions/cache@v3
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GH_PAT }}
      - name: Set DOCKER_REPO_TAGGED based on branch or tag
        run: |
          echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt:latest" >> $GITHUB_ENV
      - name: Build and publish image for main branch or tag push event
        env:
          DOCKER_REPO_TAGGED: ${{ env.DOCKER_REPO_TAGGED }}
        run: |
          docker buildx build \
          --build-arg name=app \
          --platform linux/arm64 \
          --label "org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/FastGPT" \
          --label "org.opencontainers.image.description=fastgpt image" \
          --push \
          --cache-from=type=local,src=/tmp/.buildx-cache \
          --cache-to=type=local,dest=/tmp/.buildx-cache \
          -t ${DOCKER_REPO_TAGGED} \
          -f Dockerfile \
          .

error

#32 295.6 .../node_modules/isolated-vm install$ prebuild-install || (node-gyp rebuild --release -j max && node-gyp clean)
#32 298.1 .../node_modules/isolated-vm install: prebuild-install warn install No prebuilt binaries found (target=18.17.1 runtime=node arch=arm64 libc=musl platform=linux)
#32 299.7 .../node_modules/isolated-vm install: gyp info it worked if it ends with ok
#32 299.7 .../node_modules/isolated-vm install: gyp info using [email protected]
#32 299.7 .../node_modules/isolated-vm install: gyp info using [email protected] | linux | arm64
#32 300.1 .../node_modules/isolated-vm install: gyp ERR! find Python 
#32 300.1 .../node_modules/isolated-vm install: gyp ERR! find Python Python is not set from command line or npm configuration
#32 300.1 .../node_modules/isolated-vm install: gyp ERR! find Python Python is not set from environment variable PYTHON
#32 300.1 .../node_modules/isolated-vm install: gyp ERR! find Python checking if "python3" can be used
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python - "python3" is not in PATH or produced an error
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python checking if "python" can be used
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python - "python" is not in PATH or produced an error
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python 
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python **********************************************************
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python You need to install the latest version of Python.
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python you can try one of the following options:
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python   (accepted by both node-gyp and npm)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python - Set the environment variable PYTHON
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python - Set the npm configuration variable python:
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python For more information consult the documentation at:
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python **********************************************************
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! find Python 
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! configure error 
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack Error: Could not find any Python installation to use
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/pnpm/dist/node_modules/node-gyp/lib/find-python.js:330:47)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/pnpm/dist/node_modules/node-gyp/lib/find-python.js:159:21)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/pnpm/dist/node_modules/node-gyp/lib/find-python.js:202:16)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/pnpm/dist/node_modules/node-gyp/lib/find-python.js:294:16)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at exithandler (node:child_process:427:5)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:439:5)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:289:12)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at onErrorNT (node:internal/child_process:476:16)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! System Linux 5.15.0-1061-azure
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" "-j" "max"
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! cwd /app/node_modules/.pnpm/[email protected]/node_modules/isolated-vm
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! node -v v18.17.1
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! node-gyp -v v9.3.1
#32 300.2 .../node_modules/isolated-vm install: gyp ERR! not ok 
#32 300.2 .../node_modules/isolated-vm install: Failed
#32 300.2  ELIFECYCLE  Command failed with exit code 1.

platform=amd64 can be built normally, but if you want to build an arm image you will be prompted with a python error.

@KalleV
Copy link

KalleV commented May 16, 2024

Hi @c121914yu. If you upgrade node-gyp to >=10 (preferred) or lock the Python version to the one before the distutils removal, the arm64 build should work.

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          # Lock version to avoid "distutils" error because it was removed in Python 3.12
          # See: https://github.com/nodejs/node-gyp/issues/2869
          # And: https://github.com/nodejs/node-gyp/pull/2923
          python-version: '3.11'

@c121914yu
Copy link
Author

Thx you, I switch python versions solved.

# --------- install dependence -----------
FROM python:3.11-alpine AS python_base

# 安装make和g++
RUN apk add --no-cache make g++

FROM node:20.13-alpine AS install

WORKDIR /app

ARG proxy
RUN [ -z "$proxy" ] || sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache make g++

# copy py3.11
COPY --from=python_base /usr/local /usr/local

RUN npm install -g [email protected]
RUN [ -z "$proxy" ] || pnpm config set registry https://registry.npmmirror.com

COPY pnpm-lock.yaml pnpm-workspace.yaml ./
COPY ./projects/sandbox/package.json ./projects/sandbox/package.json

RUN [ -f pnpm-lock.yaml ] || (echo "Lockfile not found." && exit 1)

RUN pnpm i

But I can't find a way to upgrade node-gyp to 10.x, it seems to specify 9.x all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants