What are the Dockerfile commands to install python-jira?

I need to run python-jira inside a Docker Container based on Ubuntu 14.04/16.04.

The default python is 2.7, but the Docker container also has python 3.

I need to access python-jira from a python3 application.

 

I added python-pip to my file system, but there is no ubuntu python-jira package.

I tried doing "RUN pip install jira" inside the Dockerfile, but that fails since I am not superuser. I then tried RUN [ "sudo",  "-A",  "pip",  "install",  "jira" ] after installing an ask-pass app which generates the password, but the build fails.

If I create a container without python-jira, I can do:

Docker> sudo pip install jira

Right now, I have an ENTRYPOINT script, and I do the "sudo -A pip install jira" in that, which allows me to "import jira", but doing it this way, adds 15-20 seconds to the startup time of the container, which is undesirable.

Also, this installs python-jira for python-2.7, not python-3.
Is there any way to install python-jira for python3 without
changing standard python with "update-alternatives" ?

So Question:

How do I get python3-jira installed in my Dockerfile which defaults python to python2?

 

2 answers

0 votes
Dave Chevell Atlassian Team May 03, 2018

Hey Ulf,

 

If you have both Python 2 and 3 installed then you should also have pip and pip3 binaries available. pip3 install python-jira should install the python-jira package into your Python 3 environment.

To answer your other questions we'll need to see your entire Dockerfile. Can you include the contents of the Dockerfile you're using? The base image in use will inform the solution you need to use here. 

Cheers,

Dave Chevell  

Here is what I tried:

The pip install python-jira fails, so right now I am rsyncing all the files

to the docker image in the "start-ale" script which is a kludge.

=========================================

FROM ubuntu:14.04
MAINTAINER N N <n.n@company.com>

ENV DEBIAN_FRONTEND noninteractive

RUN ["apt-get", "update"]
RUN ["apt-get", "upgrade", "-y", "--fix-missing"]
RUN apt-get update && apt-get -y install locales build-essential python python3 git diffstat texinfo gawk chrpath wget cpio nano vim mc iptables lzop devscripts ca-certificates gnome-terminal libcanberra-gtk3-module nfs-common python-pip python3-pip

RUN echo "root:root" | chpasswd

RUN pip install jira

RUN pip3 install jira


RUN ["locale-gen", "en_US.UTF-8"]
RUN ["dpkg-reconfigure", "locales"]

ADD start-ale /usr/local/bin/
ENTRYPOINT ["start-ale"]

============================================

start-ale:

I tried pip install here, but that adds 15-20 seconds to the startup time,

so I went with the copy instead.

===========================================

#!/bin/bash
NFS_OPTS="-o nfsvers=3,proto=tcp,nolock"

if [ "$3" == "" ] ; then
    echo "A build directory must be specified!"
    exit 1
fi

# yocto needs /dev/shm writable and it's not for some reason
chmod a+w /dev/shm

useradd -m -u $1 -g $2 -s /bin/bash builder

[ -c "$(tty)" ] && chmod a+rw $(tty)

# Zap the password for builder
[ -e /etc/shadow ] && sed -i 's%^builder:\*:%builder::%' /etc/shadow
[ -e /etc/passwd ] && sed -i 's%^builder:x:%builder::%' /etc/passwd

# Copy all files found under ale-builder-files to the docker image
cp -rp /mnt/ale-builder/ale-builder-files/home /
chown -R builder: /home
chown -R builder: /opt

cp -rp /mnt/ale-builder/ale-builder-files/usr /
cp -rp /mnt/ale-builder/ale-builder-files/etc /

# if ! [ -d /usr/local/lib/python2.7/dist-packages/jira ] ; then
#     echo "Installing python-jira"
#     sudo -A pip install --quiet jira
# fi

# Special step to make sure the ssh keys have the correct attributes
chmod 700 /home/builder/.ssh
chmod 600 /home/builder/.ssh/id_rsa
chmod 644 /home/builder/.ssh/id_rsa.pub
chmod 644 /home/builder/.ssh/known_hosts
chmod 600 /home/builder/.ssh/id_dss.openssh.px2it
chmod 600 /home/builder/.ssh/id_dss.openssh.px2drv

# Set correct build dir
sed -i 's/##BUILD_DIR##/'$3'/' /home/builder/.bashrc
sed -i 's%##HTTP_PROXY##%'$4'%' /home/builder/.bashrc

if [ -n "$SSTATE_NFS" ]; then
    mount $NFS_OPTS $SSTATE_NFS /mnt/sstate-cache
fi

if [ -n "$DL_NFS" ]; then
    mount $NFS_OPTS $DL_NFS /mnt/downloads
fi

# Start builder
if [ "$5" != "" ] ; then
    su - builder -c "$5"
    exit $?
fi

su - builder

Dave Chevell Atlassian Team May 03, 2018

Have you tried pip3 install python-jira, to ensure you're using the Python 3 pip?

This only installs python-jira for python2.7, but long term, I'd like python3

But the pip install fails in the Dockerfile, so that is the first problem.

I seem to run into an SSH problem

Step 8/13 : RUN pip install jira pbr
 ---> Running in b7c332519c5e
Downloading/unpacking jira
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1198, in prepare_files
    do_download,
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1376, in unpack_url
    self.session,
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 546, in unpack_http_url
    resp = session.get(target_url, stream=True)
  File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 467, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 237, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 455, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 558, in send
    r = adapter.send(request, **kwargs)
  File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/adapters.py", line 385, in send
    raise SSLError(e)
SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Storing debug log for failure in /root/.pip/pip.log
The command '/bin/sh -c pip install jira pbr' returned a non-zero code: 2

If I build the docker container without jira/pbr, and then do

sudo pip install jira

it succeeds.

Googling for this, indicates that our proxy might cause problems

The following commands in Dockerfile appears to work:

RUN pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org jira

RUN pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org jira

 

This only works with Ubuntu 16.04, not with Ubuntu 14.04
since pip in Ubuntu-14.04 does not support the "--trusted-host" switch

 

It would be good if a debian package was created, so apt-get install could be used.

 

Seems to be a lot of dependencies in python-jira on packages which does not have a debian package version...

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Jira

Updates to jira.atlassian.com give you visibility into what's coming in Jira Server and Data Center

Hello, Community! My name is Gosia and I'm a Product Manager on Jira Server and Data Center here at Atlassian. Since 2002 when we launched our public issue tracker, jira.atlass...

653 views 1 15
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you