Crane
Crane

Reputation: 43

How to install tkinter in a GitLab CI pipeline on a RHEL-based runner?

I am trying to run a GitLab CI pipeline on a RHEL-based runner, and I need to install the tkinter module for Python. However, I am encountering issues with permissions and package installation. Here is the relevant part of my .gitlab-ci.yml file:

test-python:
  image:
    name: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/python-39:1.0.0
    pull_policy: "if-not-present"
  tags:
    - xxxxxxxxxxxxxxxxxxx
  stage: build
  script:
  - echo "Starting pipeline..."
  - ls
  - cat /etc/os-release
  - echo "Updating system and installing tkinter..."
  - dnf update -y && dnf install -y python3-tkinter
  - echo "Installing requirements..."
  - pip install contourpy==1.3.0
  - pip install et_xmlfile==2.0.0
  - pip install cycler==0.12.1
  - pip install fonttools==4.55.3
  - pip install kiwisolver==1.4.7
  - pip install matplotlib==3.9.4
  - pip install numpy==2.0.2
  - pip install openpyxl==3.1.5
  - pip install packaging==24.2
  - pip install pandas==2.2.3
  - pip install pillow==11.0.0
  - pip install pyparsing==3.2.0
  - pip install python-dateutil==2.9.0.post0
  - pip install pytz==2024.2
  - pip install PyYAML==6.0.2
  - pip install six==1.17.0
  - pip install tzdata==2024.2
  - echo "Running unittests..."
  - cd ses_berlin_suite
  - python3 test_app.py
  - echo "Pipeline completed successfully"

When the pipeline runs, I get the following error:

Not root, Subscription Management repositories not updated
This system is not registered with an entitlement server. You can use subscription-manager to register.
Error: This command has to be run with superuser privileges (under the root user on most systems).

I have tried using sudo, but it is not available in the environment. I also do not have control over the runner configuration to ensure it runs as root.

My Questions:

  1. How can I install the tkinter module in a GitLab CI pipeline on a RHEL-based runner without root access?
  2. Is there a way to register the system with Red Hat Subscription Management within the pipeline, or is there an alternative approach to achieve this?

Any help or guidance would be greatly appreciated!

Upvotes: 0

Views: 26

Answers (1)

KMZ
KMZ

Reputation: 606

  1. Use a different image that has sudo and/or uses root as a default user, or build a custom image with tkinter already baked in.

  2. Why would you want to register an ephemeral RHEL-based container? The only reason I can think of is if you depend on something that doesn't exist for other RHEL equivalents (Fedora, CentOS, Rocky, Alma and so on) and needs to be installed from RedHat repos, otherwise I would use official Fedora images.

  3. Don't install requirement this way. Use requirements.txt or some other method supported by your choice of Python package management, but please don't hardcode anything in the pipeline code -- it's hard to maintain and almost impossible to use locally. You will thank me later.

Upvotes: 0

Related Questions