3

Im trying to install a package on the host system i.e (ubuntu-latest) before entering the docker container (arch linux)

I tried a lot of syntax but Im getting it wrong

on: [push]
jobs:
  update-aur:
    runs-on: ubuntu-latest
    steps:
      - run : sudo apt-get install runc
    container: archlinux
    steps:
      - run: |
          pacman --noconfirm -Syu 
          pacman --noconfirm -S base-devel 

this gives an error of steps is already defined

sonu ishaq
  • 101
  • 14
  • 1
    what is the use case here? why do you need `runc` if you are using the conatiner? – Tarun Lalwani Feb 23 '21 at 09:08
  • Thats one of the dependencies needed to run arch linux container properly in debian based systems at least thats what I got from the forum https://bugs.archlinux.org/task/69563 – sonu ishaq Feb 25 '21 at 02:10
  • 1
    Then may be you need to use `uses` in the second step, which can call another action. See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses. I assume that the action will run on the same container only. So you can actually setup two actions, one to setup runc and one to execute the the container you have call both of them in your main script – Tarun Lalwani Feb 25 '21 at 05:36

3 Answers3

1

If the running machine configuration is important for the build, try using self-hosted runner.

  1. You can create VM in some of the cloud providers (ex. AWS, Azure, etc.) and register it with GitHub-CI.
  2. Install the GitHub-CI service
  3. Install all the utilities you need
  4. Register the runner to the repository
  5. Change the build script for run-on to point to the self-hoster runner

You can find more information in the GitHub-CI Docs

jordanvrtanoski
  • 5,104
  • 1
  • 20
  • 29
1

You could run only a step in the container instead of the whole job. Something like:

on: [push]
jobs:
  update-aur:
    runs-on: ubuntu-latest
    steps:
      - run: sudo apt-get install ...
      - uses: docker://archlinux
        with:
          entrypoint: /usr/bin/bash
          args: -c 'pacman --noconfirm -Syu && pacman --noconfirm -S base-devel'

I don't know if it's practical in your case since you probably want to run a bunch of steps afterward in the same container. In any case you can find more info on the running steps in containers here and the different options available here

ITChap
  • 4,057
  • 1
  • 21
  • 46
  • 1
    You can't install new OS level packages for runner operating system. You can get more information for [GitHub Docs][1]. In this case, ubuntu-latest machine has been used, and available tools/packages can be found from [here.][2] [1]: https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-software [2]: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md – Niklas Feb 26 '21 at 17:09
  • @Niklas I just gave it a try and it works fine. Unfortunately install runc like the OP asked for seems to break docker and the second step doesn't work anymore. – ITChap Feb 27 '21 at 14:31
  • My bad, indeed it is possible https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners – Niklas Feb 27 '21 at 14:34
0

You can mount the docker socket from the host into the container, and you can start a privileged container that shares the pid namespace with the host. Each of these give you options to reach out of the container later.

container:
  image: quay.io/buildah/stable:latest
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  options: --privileged --pid=host

Through the mounted docker socket, you can talk to the docker daemon on the host.

Thanks to --privileged --pid=host, you can use nsenter to escape from the container, as explained in https://stackoverflow.com/a/63140387/1047788

user7610
  • 25,267
  • 15
  • 124
  • 150