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
687 stars 155 forks source link

Running the 'docker' command from run-on-arch #33

Closed marco-brandizi closed 3 years ago

marco-brandizi commented 3 years ago

I'd like to test my multiple-architecture Docker image, hence, I've tried the run-on-arch action, together with the docker command. Something like this:

name: Docker Test
on:
  workflow_dispatch
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Code checkout
      uses: actions/checkout@v2.3.4

    - uses: uraimo/run-on-arch-action@v2.0.9
      name: Run aratiny
      id: docker-cmd
      env:
        DOCKER_USER: ${{secrets.DOCKER_USER}}
        DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
      with:
        arch: aarch64
        distro: ubuntu20.04
        run: |
          cd docker
          ./docker-run.sh # this just sets up a few options and runs "docker run".

However, I get the error 'docker command not found':

Status: Downloaded newer image for arm64v8/ubuntu:20.04
 ---> 0a1fc7bf1e73
Step 2/3 : COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
 ---> 24140215138a
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) does not match the detected host platform (linux/amd64) and no specific platform was requested
 ---> Running in 85e80b14444c
Removing intermediate container 85e80b14444c
 ---> 833ef66bca6f
Successfully built 833ef66bca6f
Successfully tagged run-on-arch-rothamsted-knetminer-docker-test-aarch64-ubuntu20-04:latest
WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64) and no specific platform was requested

export MAVEN_ARGS=" --no-transfer-progress --batch-mode --no-snapshot-updates -Pdocker"
++ docker run -it -p 8080:8080 --env MAVEN_ARGS knetminer/knetminer:latest aratiny
./docker-run.sh: line 144: docker: command not found
Error: The process '/home/runner/work/_actions/uraimo/run-on-arch-action/v2.0.9/src/run-on-arch.sh' failed with exit code 127

Details here.

Usually, the docker command is available in the GH Actions host, without anything special to set, here it seems it isn't.

Moreover, as I asked elsewhere, I'm not sure that I should prepare multi-arch images for all the parents that my image uses, or if doing it just for the latter is enough.

uraimo commented 3 years ago

These images we use have the bare minimum inside (even the apt cache have been stripped), so you'll have to run a "apt update;apt ugrade" and "apt install docker-ce docker-ce-cli containerd.io" or variations to install docker. Once done, docker should work I suppose.

marco-brandizi commented 3 years ago

Thanks. @uraimo, I'll try it. So, you mean, there isn't a default Docker image that it's used by all the builds and all the actions add up to it?

uraimo commented 3 years ago

Exactly, no single docker image since the OS Distro is different and depending on the arch you choose. You can take a look at the actual image being used for every os/arch combination here. But one thing that is common to all of them is that to reduce the size of the image, all of them are stripped of any cache or content that can be automatically downloaded again. For example the apt cache. In you case, consider these image to be as minimal as possible, so every thing you need you'll need to install it (for example docker, that should be 300Mb or so).

marco-brandizi commented 3 years ago

Thanks, what I actually meant is that I was assuming there is an image that can be set at the beginning of the config file and that GH Actions uses for all the build steps and actions. Instead, it seems that every action can set up its own image.

uraimo commented 3 years ago

Yes exactly, every step is independent and defines a new emulated context that has its lifetime limited to the step you are in. The step following a run-on-arch one starts back in the default amd64 enviroment.