DEV Community

Kay
Kay

Posted on • Updated on

Gotchas when building GitHub self-hosted runners with AWS official AMIs/container images for Python apps

The following are some gotchas when setting up specific Python versions on GitHub self-hosted runners which are based on AWS official AMIs and container images.

  1. Official Amazon Linux 2 AMI and official Amazon Linux 2 container image do not have the same Python runtimes setup.

    • Amazon Linux 2 AMI (ECS-optimized AMI /aws/service/ecs/optimized-ami/amazon-linux-2/recommended) has python2.7 and python3.7 by default.
    • Amazon Linux 2 container image amazonlinux/amazonlinux (public.ecr.aws/amazonlinux/amazonlinux) has only python2.7; it does not have python3/pip installed by default.
  2. Amazon Linux 2 AMI has python3 pointed to python3.7 by default. When changing python3 to point to other Python3 version (e.g. setting update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1), it may break cfn-signal so no signal will be sent to ASG at EC2 launch (i.e. no healthy instances will be registered).
    Note that this will be an issue if you use ASG for the runners (not ECS Fargate).

  3. Keep python to point to python2.7, as yum does not support Python3. You will see this error if setting python to point to Python3:

    > yum
    File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:
                           ^
    SyntaxError: invalid syntax
    

    See also https://stackoverflow.com/questions/11213520/yum-crashed-with-keyboard-interrupt-error.

  4. actions/setup-python@v4 does not support arm64 (https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json).
    See related Open issue https://github.com/actions/setup-python/issues/108.

Note: (3) and (4) are not Amazon Linux specific. Just issues experienced when building the Amazon official image based self-hosted runners.

Top comments (0)