Skip to content

Commit

Permalink
update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Jul 12, 2017
1 parent ba8f48e commit 2bc1a2d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 7 deletions.
32 changes: 25 additions & 7 deletions images/installer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Using playbook2image as a base
# See https://github.com/openshift/playbook2image for details on the image
# including documentation for the settings/env vars referenced below
FROM registry.centos.org/openshift/playbook2image:latest
FROM openshift/base-centos7

MAINTAINER OpenShift Team <dev@lists.openshift.redhat.com>

Expand All @@ -12,10 +12,31 @@ LABEL name="openshift/origin-ansible" \
io.k8s.display-name="openshift-ansible" \
io.k8s.description="A containerized openshift-ansible image to let you run playbooks to install, upgrade, maintain and check an OpenShift cluster" \
io.openshift.expose-services="" \
io.openshift.tags="openshift,install,upgrade,ansible"
io.openshift.tags="openshift,install,upgrade,ansible" \
vcs-url="https://github.com/openshift/openshift-ansible" \
vcs-type="git" \
version="alpha"

USER root

# ansible and pip are in EPEL
RUN yum install -y epel-release && yum clean all -y

# workaround for https://github.com/openshift/openshift-ansible/issues/3111
# install ansible via pip to lock version
RUN yum install -y --setopt=tsflags=nodocs python-pip python-devel && yum clean all -y
RUN pip install -Iv ansible==2.2.0.0

COPY ./bin /usr/bin
COPY ./bin/user_setup /tmp

RUN mkdir -p /opt/app-root /opt/app-root/etc /opt/app-root/bin
RUN chmod -R ug+x /opt/app-root/bin /opt/app-root/etc /tmp/user_setup && \
/tmp/user_setup

# Add files for running as a system container
COPY ./system-container/root /

# Create a symlink to /opt/app-root/src so that files under /usr/share/ansible are accessible.
# This is required since the system-container uses by default the playbook under
# /usr/share/ansible/openshift-ansible. With this change we won't need to keep two different
Expand Down Expand Up @@ -43,9 +64,6 @@ ADD . /tmp/src
# Running the 'assemble' script provided by playbook2image will install
# dependencies specified in requirements.txt and install the 'oc' client
# as per the INSTALL_OC environment setting above
RUN /usr/libexec/s2i/assemble

# Add files for running as a system container
COPY images/installer/system-container/root /
RUN /usr/bin/assemble

CMD [ "/usr/libexec/s2i/run" ]
CMD [ "/usr/bin/run" ]
48 changes: 48 additions & 0 deletions images/installer/bin/assemble
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

0 comments on commit 2bc1a2d

Please sign in to comment.