inveniosoftware / docker-invenio

Docker base images for Invenio.
https://docker-invenio.readthedocs.io
MIT License
10 stars 34 forks source link

Change in default python in centos 7 makes yum fail #15

Closed ppanero closed 5 years ago

ppanero commented 5 years ago

By changing the default python version from 2 to 3.6 yum among other system tools stop working, since they need python2 to work. For example:

[root@localhost]# yum
  File "/usr/bin/yum", line 30
   except KeyboardInterrupt, e:
                        ^

I need yum & co to extend with some extra libraries that cannot be installed via pip, therefore I wanted to extend the image. For now my fix was to revert the default momentarily:

# Set python2 as default to make yum work
RUN alternatives --set python /usr/bin/python2
# Install pre-requisites
RUN yum update -y && \
    yum install -y <libraries>
RUN yum clean -y all

# Fall back to python3 as default
RUN alternatives --set python /usr/bin/python3.6

However, I have to know which python version was setted in the Invenio image and hardcode it to fall back. It cannot be taken from the environment since python3 has a symbolic link to python3.4.

Is there a more elegant solution? Thanks!

tiborsimko commented 5 years ago

As an alternative to #16 what about a simple technique of not using yum but relying on rpm directly?

$ docker run -i -t --rm centos:7 /bin/bash
[root@c76e0b166ac8 /]# rpm -Uvh http://download.fedoraproject.org/pub/epel/7/x86_64/Packages/g/gnugo-3.8-18.el7.x86_64.rpm
[root@c76e0b166ac8 /]# gnugo --help

If you only need a couple of packages and their dependencies, then it should be quick to construct a list of URLs you need for their installation and avoid using yum altogether. The EPEL URLs are pretty stable and pinning package versions may be considered an advantage.

If you need many packages with inter-connected dependencies, then this technique wouldn't be that great, although you could still use yum install <libraries> in an empty centos:7 container and use rpm -qa before and after to construct the list of your packages that to be installed via rpm -Uvh.

It may not be the most elegant solution, but should be quick and works without any upstream changes :wink:

Glignos commented 5 years ago

Solved by https://github.com/inveniosoftware/docker-invenio/pull/16