From 4797dd23439744664bef0a03c7f6f6e3e9608760 Mon Sep 17 00:00:00 2001 From: Mangirdas Date: Thu, 27 Sep 2018 12:19:11 +0100 Subject: [PATCH] add mount files for nion priv run --- projects/azure/base-images/test-base.yaml | 9 +++++++++ .../test-base/root/usr/local/bin/entrypoint | 17 +++++++++++++++++ .../test-base/root/usr/local/bin/user_setup | 19 +++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 projects/azure/base-images/test-base/root/usr/local/bin/entrypoint create mode 100644 projects/azure/base-images/test-base/root/usr/local/bin/user_setup diff --git a/projects/azure/base-images/test-base.yaml b/projects/azure/base-images/test-base.yaml index f2459f34ada2..757fd79364ed 100644 --- a/projects/azure/base-images/test-base.yaml +++ b/projects/azure/base-images/test-base.yaml @@ -21,6 +21,10 @@ items: kind: ImageStreamTag name: test-base:latest source: + git: + uri: "https://github.com/openshift/release" + ref: "master" + contextDir: "projects/azure/base-images/test-base" dockerfile: | FROM docker.io/centos:7 # install golang-1.10 @@ -51,6 +55,11 @@ items: go get golang.org/x/tools/cmd/goimports && \ chmod 777 -R /go/bin RUN yum clean all + # Add image scripts and files for running as non priv container + COPY root / + RUN /usr/local/bin/user_setup + USER ${USER_UID} + ENTRYPOINT [ "/usr/local/bin/entrypoint" ] type: Dockerfile strategy: dockerStrategy: diff --git a/projects/azure/base-images/test-base/root/usr/local/bin/entrypoint b/projects/azure/base-images/test-base/root/usr/local/bin/entrypoint new file mode 100644 index 000000000000..03998f7e88d8 --- /dev/null +++ b/projects/azure/base-images/test-base/root/usr/local/bin/entrypoint @@ -0,0 +1,17 @@ +#!/bin/bash -e +# +# This file serves as the main entrypoint to the azure image. +# +# For more information see the documentation in openshift-ansible +# https://github.com/openshift/openshift-ansible/blob/master/README_CONTAINER_IMAGE.md + + +# Patch /etc/passwd file with the current user info. +# The current user's entry must be correctly defined in this file in order for +# the `ssh` command to work within the created container. + +if ! whoami &>/dev/null; then + echo "${USER:-default}:x:$(id -u):$(id -g):Default User:$HOME:/sbin/nologin" >> /etc/passwd +fi + +exec "$@" diff --git a/projects/azure/base-images/test-base/root/usr/local/bin/user_setup b/projects/azure/base-images/test-base/root/usr/local/bin/user_setup new file mode 100644 index 000000000000..24ed156fa7bf --- /dev/null +++ b/projects/azure/base-images/test-base/root/usr/local/bin/user_setup @@ -0,0 +1,19 @@ +#!/bin/sh +set -x + +# ensure $HOME exists and is accessible by group 0 (we don't know what the runtime UID will be) +mkdir -p ${HOME} +chown ${USER_UID}:0 ${HOME} +chmod ug+rwx ${HOME} + +# runtime user will need to be able to self-insert in /etc/passwd +chmod g+rw /etc/passwd + +# ensure that the image content is accessible +chmod -R g+r ${WORK_DIR} +find ${WORK_DIR} -type d -exec chmod g+x {} + +# ensure that the dynamic inventory dir can have content created +find ${WORK_DIR} -type d -exec chmod g+wx {} + + +# no need for this script to remain in the image after running +rm $0