-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba8f48e
commit 2bc1a2d
Showing
2 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash -e | ||
# | ||
# Assemble script for the openshift/openshift-ansible image. | ||
# The 'assemble' script builds the application source so that it is ready to run. | ||
# | ||
# For more information refer to the documentation: | ||
# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md | ||
# | ||
|
||
if [[ "$1" == "-h" ]]; then | ||
# If the 'playbook2image' assemble script is executed with '-h' flag, | ||
# print the usage. | ||
exec /usr/bin/usage | ||
fi | ||
|
||
# Restore artifacts from the previous build (if they exist). | ||
# | ||
if [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then | ||
echo "---> Restoring build artifacts..." | ||
mv /tmp/artifacts/. ./ | ||
fi | ||
|
||
echo "---> Installing application source..." | ||
cp -Rf /tmp/src/. ./ | ||
|
||
echo "---> Building application from source..." | ||
# pre-create PYTHONUSERBASE/lib/*, otherwise pip creates it with mode 0700 | ||
# which prevents containers with arbitrary UIDs to access local packages | ||
mkdir -p ${HOME}/.local/lib/python2.7/site-packages | ||
if [[ -v PYTHON_REQUIREMENTS ]]; then | ||
pip install --no-cache-dir -r ${PYTHON_REQUIREMENTS} | ||
elif [[ -e requirements.txt ]]; then | ||
pip install --no-cache-dir --user -r requirements.txt | ||
fi | ||
|
||
if [[ -v INSTALL_OC ]]; then | ||
pip install --no-cache-dir --user requests | ||
echo "---> Installing 'oc' binary..." | ||
TMPDIR=$(mktemp -d) | ||
cd ${TMPDIR} | ||
OC_BINARY_URL=$(python -c "import requests;releases = requests.get('https://api.github.com/repos/openshift/origin/releases').json();print [s for s in [r for r in releases if not r['prerelease'] and '1.4' in r['name']][0]['assets'] if 'linux-64' in s['browser_download_url']][0]['browser_download_url']") | ||
curl -L ${OC_BINARY_URL} -o openshift-client.tar.gz | ||
OC_PATH=`tar -tzf openshift-client.tar.gz |grep oc` | ||
tar -xzf openshift-client.tar.gz ${OC_PATH} | ||
cp ${OC_PATH} ${APP_ROOT}/bin/oc | ||
cd .. | ||
rm -rf ${TMPDIR} | ||
fi |