inveniosoftware / docker-invenio

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

installation: fix yum failing in images extending from docker-invenio #16

Closed diegodelemos closed 5 years ago

diegodelemos commented 5 years ago
diegodelemos commented 5 years ago

@ppanero I have found this to be the cleanest way but still there is a problem with pipenv and RH CSL..., an usage example:

~/docker-invenio $ docker build python3.6/ -t inveniosoftware/centos7-python

New Dockerfile Dockerfile.the.descendent:

FROM inveniosoftware/centos7-python
RUN yum install -y htop
RUN python -V
~/docker-invenio $ docker build -f python3.6/Dockerfile.the.descendent . -t the.descendent
Sending build context to Docker daemon  400.4kB
Step 1/3 : FROM inveniosoftware/centos7-python
 ---> fd8f8259f6af
Step 2/3 : RUN yum install -y htop

 ---> Running in b270d88efead
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: linuxsoft.cern.ch
 * epel: mirror.ibcp.fr
 * extras: linuxsoft.cern.ch
 * ius: mirror.ehv.weppel.nl
 * updates: linuxsoft.cern.ch
Resolving Dependencies
--> Running transaction check
---> Package htop.x86_64 0:2.2.0-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch              Version                Repository       Size
================================================================================
Installing:
 htop            x86_64            2.2.0-1.el7            epel            103 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 103 k
Installed size: 218 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : htop-2.2.0-1.el7.x86_64                                      1/1
  Verifying  : htop-2.2.0-1.el7.x86_64                                      1/1

Installed:
  htop.x86_64 0:2.2.0-1.el7

Complete!
Removing intermediate container b270d88efead
 ---> 62339db10713
Step 3/3 : RUN python -V
 ---> Running in 42699abcad06
Python 3.6.3
Removing intermediate container 42699abcad06
 ---> 544486581871
Successfully built 544486581871
Successfully tagged test:latest

Then everything should be run with bash, that's why the SHELL instruction, for example:

~/docker-invenio $ docker run -ti --rm the.descendent /bin/bash -c 'python -V'
Python 3.6.3
~/docker-invenio $ docker run -ti --rm the.descendent python -V
Python 2.7.5
~/docker-invenio $ docker run -ti --rm the.descendent /bin/bash -c 'pipenv install requests'
Creating a virtualenv for this project…
Pipfile: /opt/invenio/src/Pipfile
Using /opt/rh/rh-python36/root/usr/bin/python3 (3.6.3) to create virtualenv…
⠦ Creating virtual environment...Already using interpreter /opt/rh/rh-python36/root/usr/bin/python3
Using base prefix '/opt/rh/rh-python36/root/usr'
New python executable in /root/.local/share/virtualenvs/src--FJPeFkS/bin/python3
Also creating executable in /root/.local/share/virtualenvs/src--FJPeFkS/bin/python
Installing setuptools, pip, wheel...
done.

✔ Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/src--FJPeFkS
Creating a Pipfile for this project…
Installing requests…
Adding requests to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (b14837)!
Installing dependencies from Pipfile.lock (b14837)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 5/5 — 00:00:01
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

But if I login into the image with random user (as OpenShift is going to do):

~/docker-invenio $ docker run --user 99999 -ti --rm the.descendent
bash-4.2$ source /etc/bashrc
bash: history: //.bash_history: cannot create: Permission denied
/usr/bin/id: cannot find name for user ID 99999
[I have no name!@0b21446209b0 src]$ history
    1  source /etc/bashrc
    2  history
[I have no name!@0b21446209b0 src]$ pipenv install requests
Traceback (most recent call last):
  File "/opt/rh/rh-python36/root/usr/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/cli/command.py", line 254, in install
    editable_packages=state.installstate.editables,
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/core.py", line 1741, in do_install
    pypi_mirror=pypi_mirror,
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/core.py", line 574, in ensure_project
    pypi_mirror=pypi_mirror,
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/core.py", line 489, in ensure_virtualenv
    if not project.virtualenv_exists:
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/project.py", line 272, in virtualenv_exists
    if self.pipfile_exists and os.path.exists(self.virtualenv_location):
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/project.py", line 437, in virtualenv_location
    self._virtualenv_location = self.get_location_for_virtualenv()
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/project.py", line 294, in get_location_for_virtualenv
    return str(get_workon_home().joinpath(self.virtualenv_name))
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/utils.py", line 1414, in get_workon_home
    mkdir_p(str(expanded_path))
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/utils.py", line 864, in mkdir_p
    mkdir_p(head)
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/utils.py", line 864, in mkdir_p
    mkdir_p(head)
  File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pipenv/utils.py", line 869, in mkdir_p
    os.mkdir(newdir)
PermissionError: [Errno 13] Permission denied: '/.local'