uraimo / run-on-arch-action

A Github Action that executes jobs/commands on non-x86 cpu architectures (ARMv6, ARMv7, aarch64, s390x, ppc64le, riscv64) via QEMU
BSD 3-Clause "New" or "Revised" License
677 stars 149 forks source link

Volume is not mounted #79

Open jokaorgua opened 2 years ago

jokaorgua commented 2 years ago

Hello.

Could anyone guide me how to mount current directory into the aarch64 container?

I'm trying to do that with

dockerRunarg: |
  --volume "${PWD}:/app"

but the volume is not mounted

Run uraimo/run-on-arch-action@v2
Configuring Docker for multi-architecture support
/home/runner/work/_actions/uraimo/run-on-arch-action/v2/src/run-on-arch.sh /home/runner/work/_actions/uraimo/run-on-arch-action/v2/Dockerfiles/Dockerfile.aarch64.ubuntu20.04 run-on-arch-jokaorgua-for-files-ci-aarch64-ubuntu20-04 --volume ${PWD}:/app
Build container
  GitHub token provided, caching to ghcr.io/jokaorgua/for_files/run-on-arch-jokaorgua-for-files-ci-aarch64-ubuntu20-04
  WARNING! Your password will be stored unencrypted in /home/runner/.docker/config.json.
  Configure a credential helper to remove this warning. See
  https://docs.docker.com/engine/reference/commandline/login/#credentials-store

  Login Succeeded
  Error response from daemon: manifest unknown
  Sending build context to Docker daemon  61.44kB

  Step 1/3 : FROM arm64v8/ubuntu:20.04
  20.04: Pulling from arm64v8/ubuntu
  d4ba87bb7858: Pulling fs layer
  d4ba87bb7858: Verifying Checksum
  d4ba87bb7858: Download complete
  d4ba87bb7858: Pull complete
  Digest: sha[25](https://github.com/jokaorgua/for_files/runs/6324683489?check_suite_focus=true#step:4:25)6:ca83774d06420ceb4682ef73bd9cbbfc38a97a[27](https://github.com/jokaorgua/for_files/runs/6324683489?check_suite_focus=true#step:4:27)e061b578547a6761206658b9
  Status: Downloaded newer image for arm64v8/ubuntu:20.04
   ---> db1bc6aa58da
  Step 2/3 : COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
   ---> 95ef0[31](https://github.com/jokaorgua/for_files/runs/6324683489?check_suite_focus=true#step:4:31)9085f
  Step 3/3 : RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
  Warning: rning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
   ---> Running in 55c58bc0ca7a
  /root/run-on-arch-install.sh: line 4: cd: /app: No such file or directory

Here is my workflow

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  test:
    # This workflow contains a single job called "build"
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - arch: aarch64
            distro: ubuntu20.04
            build-targets: "deb"
            os: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        name: Checkout branch
      - run: echo ${PWD}
      - uses: uraimo/run-on-arch-action@v2
        name: setup aarch container
        with:
          arch: ${{ matrix.arch }}
          distro: ${{ matrix.distro }}
          # Not required, but speeds up builds
          githubToken: ${{ github.token }}
          shell: /bin/bash
          # Mount the artifacts directory as /artifacts in the container
          dockerRunArgs: |
            --volume "${PWD}:/app"
          install: |
            cd /app
            ls -la
            apt update
            apt install -y curl ruby-dev build-essential
            gem i fpm -f
            curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
            source ~/.nvm/nvm.sh
            nvm use v16.13.2
            nvm installnvm
          run: |
            uname -a
            node --version
            nvm --version
dionysius commented 1 year ago

The issue seems to still be present. Any of my matrices fail on the same spot. I also tried using the github.workspace variable:

          dockerRunArgs: |
            --volume "${{ github.workspace }}:/work"
          install: |
            ls -lah /work

resulting in:

Run uraimo/run-on-arch-action@v2
Configuring Docker for multi-architecture support
/home/runner/work/_actions/uraimo/run-on-arch-action/v2/src/run-on-arch.sh /home/runner/work/_actions/uraimo/run-on-arch-action/v2/Dockerfiles/Dockerfile.armv7.ubuntu_latest run-on-arch-dionysius-repo-job-armv7-ubuntu-latest --volume /home/runner/work/repo/repo:/work
Build container
...
/usr/bin/ls: cannot access '/work': No such file or directory

Is there an usage error on our side?

martin-g commented 1 year ago

I've never had this problem in any of my projects. E.g. https://github.com/lh3/bwa/blob/139f68fc4c3747813783a488aef2adc86626b01b/.github/workflows/ci.yaml#L40-L45

dionysius commented 1 year ago

Weird, yeah I can't figure out what I'm doing wrong.

Current workflow: https://github.com/dionysius/pyznap-deb/blob/gha_xcompile_archaction/.github/workflows/packaging.yml#L102 Results in: https://github.com/dionysius/pyznap-deb/actions/runs/3893904901

Job log extract:

Run uraimo/run-on-arch-action@v2
Configuring Docker for multi-architecture support
/home/runner/work/_actions/uraimo/run-on-arch-action/v2/src/run-on-arch.sh /home/runner/work/_actions/uraimo/run-on-arch-action/v2/Dockerfiles/Dockerfile.riscv64.ubuntu_latest run-on-arch-dionysius-pyznap-deb-deb-packaging-riscv64-ubuntu-latest --volume ${PWD}:/work
Build container
...
Step 3/3 : RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
  Warning: rning] The requested image's platform (linux/riscv64) does not match the detected host platform (linux/amd64) and no specific platform was requested
   ---> Running in 5ed370177a65
  total 60K
  drwxr-xr-x   1 root root 4.0K Jan 11 14:49 .
  drwxr-xr-x   1 root root 4.0K Jan 11 14:49 ..
  -rwxr-xr-x   1 root root    0 Jan 11 14:49 .dockerenv
  lrwxrwxrwx   1 root root    7 Nov 30 02:45 bin -> usr/bin
  drwxr-xr-x   2 root root 4.0K Apr 18  2022 boot
  drwxr-xr-x   5 root root  340 Jan 11 14:49 dev
  drwxr-xr-x   1 root root 4.0K Jan 11 14:49 etc
  drwxr-xr-x   2 root root 4.0K Apr 18  2022 home
  lrwxrwxrwx   1 root root    7 Nov 30 02:45 lib -> usr/lib
  drwxr-xr-x   2 root root 4.0K Nov 30 02:45 media
  drwxr-xr-x   2 root root 4.0K Nov 30 02:45 mnt
  drwxr-xr-x   2 root root 4.0K Nov 30 02:45 opt
  dr-xr-xr-x 218 root root    0 Jan 11 14:49 proc
  drwx------   1 root root 4.0K Jan 11 14:49 root
  drwxr-xr-x   5 root root 4.0K Nov 30 03:[57](https://github.com/dionysius/pyznap-deb/actions/runs/3893904901/jobs/6647149571#step:3:58) run <-- buggy line, ignore ^^
  lrwxrwxrwx   1 root root    8 Nov 30 02:45 sbin -> usr/sbin
  drwxr-xr-x   2 root root 4.0K Nov 30 02:45 srv
  dr-xr-xr-x  12 root root    0 Jan 11 14:49 sys
  drwxrwxrwt   2 root root 4.0K Nov 30 03:55 tmp
  drwxr-xr-x  11 root root 4.0K Nov 30 02:45 usr
  drwxr-xr-x  11 root root 4.0K Nov 30 03:55 var
  /usr/bin/ls: cannot access '/work': No such file or directory
  The command '/bin/sh -c chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh' returned a non-zero code: 2
martin-g commented 1 year ago

You try to use /work at install time. I always used it at run time. I guess this is by design since the argument name is dockerRunArgs

dionysius commented 1 year ago

Yep, this is it! I think its more of a docker thing and I don't work with docker that often but it seems that the install stage has the volume not yet mounted. Fixed for me.

Also at OP: @jokaorgua, move commands which use the mounted folder to run.

uraimo commented 1 year ago

Hi all and thanks, the conclusion is correct, install commands are executed in the first phase of the creation of the image while runArgs are only used when the container actually runs and executes the commands of the run section. In this case every use of /apps should be moved to the run section.