Openshift:如何从私有存储库安装python模块? [英] Openshift: how to install python modules from private repository?

查看:117
本文介绍了Openshift:如何从私有存储库安装python模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将python软件包安装到openshift,但是这些软件包存在于我的私有存储库中,位于bitbucket上.

I would like to be able to install python packages to openshift, but those packages live in my private repositories, on bitbucket.

如何为Openshift创建SSH密钥,以及如何在安装软件包时使Openshift使用它? (在将相应的公钥添加到bitbucket作为部署密钥之后)

How can I create a SSH key for Openshift, and how do I make Openshift use it when installing packages? (after adding the corresponding public key to bitbucket as a Deploy Key)

我尝试过的事情:

我用ssh-keygen~/.openshift_ssh/上创建了一个密钥.它已创建,但我不确定它是否正在使用.

I used ssh-keygen to create a key on ~/.openshift_ssh/. It was created, but I'm not sure it is being used.

我也尝试在<jenkins_dir>/app-root/data/.ssh/jenkins_id_rsa.pub上添加publick密钥,但结果始终相同.在buildjob的jenkins控制台输出上:

I also tried adding the publick key on <jenkins_dir>/app-root/data/.ssh/jenkins_id_rsa.pub, but the result is always the same. On the jenkins console output of the buildjob:

Doing git clone from ssh://git@bitbucket.org/jpimentel/zed.git to /tmp/easy_install-FpEKam/zed.git
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

有什么可以做的吗?

推荐答案

因此,此时OpenShift不提供执行此操作的简单机制.我敦促开发人员查看 https://gondor.io/support/dependencies/以获取有效的解决问题的方法.

So, at this time OpenShift does not offer a simple mechanism to do this. I would urge developers to look at https://gondor.io/support/dependencies/ for an effective solution to the problem.

也就是说,我终于可以通过以下过程找到一种适用于可伸缩和不可伸缩应用程序的可接受的解决方法(至少对我而言):

That said, I was finally able to find an acceptable (at least, for me) workaround that works on both scalable and non scalable apps, with the following procedure:

  1. 在存储库中创建一个deploy/目录

  1. create a deploy/ directory in the repository

将您的私有部署密钥的副本放入所述目录

put a copy of your private deploy key in said directory

创建一个bash脚本deploy/wrapper.sh,它将使用提供的密钥运行ssh:

create a bash script deploy/wrapper.sh that will run ssh with the provided key:

#!/bin/sh
ssh -o StrictHostKeyChecking=no -i $OPENSHIFT_REPO_DIR/deploy/id_deploy $@

请注意传递的禁用主机密钥检查的选项;没有它,克隆将失败.

note the option passed to disable host key check; cloning will fail without it.

在构建挂钩(.openshift/action_hooks/build)中安装依赖项.就我而言,我添加了类似的内容

install dependencies in the build hook (.openshift/action_hooks/build). In my case I added something like

echo "Cloning private repo..."
source $VIRTUAL_ENV/bin/activate
GIT_SSH=$OPENSHIFT_REPO_DIR/deploy/wrapper.sh pip install git+ssh://git@bitbucket.org/team/reponame.git#egg=reponame

  • 提交所有内容并将其推送到openshift.

  • commit everything and push it to openshift.

    利润!

    这篇关于Openshift:如何从私有存储库安装python模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆