#5 Update from the upstream https://github.com/sclorg/httpd-container
Opened 5 years ago by mskalick. Modified 5 years ago
container/ mskalick/httpd f28  into  f28

file modified
+7 -3
@@ -1,4 +1,4 @@ 

- FROM registry.fedoraproject.org/f28/s2i-core:latest

+ FROM registry.fedoraproject.org/f28/s2i-base:latest

  

  # Apache HTTP Server image.

  #
@@ -8,7 +8,10 @@ 

  # Environment:

  #  * $HTTPD_LOG_TO_VOLUME (optional) - When set, httpd will log into /var/log/httpd

  

- ENV HTTPD_VERSION=2.4 NAME=httpd VERSION=$HTTPD_VERSION RELEASE=2 ARCH=x86_64

+ ENV HTTPD_VERSION=2.4 \

+     NAME=httpd \

+     RELEASE=1 \

+     ARCH=x86_64

  

  ENV SUMMARY="Platform for running Apache httpd $HTTPD_VERSION or building httpd-based application" \

      DESCRIPTION="Apache httpd $HTTPD_VERSION available as container, is a powerful, efficient, \
@@ -25,7 +28,7 @@ 

        io.openshift.tags="builder,httpd,httpd24" \

        com.redhat.component="$NAME" \

        name="$FGC/$NAME" \

-       version="2.4" \

+       version="$HTTPD_VERSION" \

        release="$RELEASE.$DISTTAG" \

        architecture="$ARCH" \

        usage="s2i build https://github.com/sclorg/httpd-container.git --context-dir=examples/sample-test-app/ $FGC/$NAME sample-server" \
@@ -44,6 +47,7 @@ 

      HTTPD_APP_ROOT=${APP_ROOT} \

      HTTPD_CONFIGURATION_PATH=${APP_ROOT}/etc/httpd.d \

      HTTPD_MAIN_CONF_PATH=/etc/httpd/conf \

+     HTTPD_MAIN_CONF_MODULES_D_PATH=/etc/httpd/conf.modules.d \

      HTTPD_MAIN_CONF_D_PATH=/etc/httpd/conf.d \

      HTTPD_VAR_RUN=/var/run/httpd \

      HTTPD_DATA_PATH=/var/www \

file modified
+16
@@ -113,6 +113,10 @@ 

         By default, httpd logs into standard output, so the logs are accessible by using the docker logs command. When \fB\fCHTTPD\_LOG\_TO\_VOLUME\fR is set, httpd logs into \fB\fC/var/log/httpd24\fR, which can be mounted to host system using the container volumes. This option is only allowed when container is run as UID 0.

  

  .PP

+ \fB\fB\fCHTTPD\_MPM\fR\fP

+        The variable \fB\fCHTTPD\_MPM\fR can be set to change the default Multi\-Processing Module (MPM) from the package default MPM.

+ 

+ .PP

  If you want to run the image and mount the log files into \fB\fC/wwwlogs\fR on the host

  as a container volume, execute the following command:

  
@@ -126,6 +130,18 @@ 

  .RE

  

  .PP

+ To run an image using the \fB\fCevent\fR MPM (rather than the default \fB\fCprefork\fR), execute the following command:

+ 

+ .PP

+ .RS

+ 

+ .nf

+ $ docker run \-d \-e HTTPD\_MPM=event \-\-name httpd rhscl/httpd\-24\-rhel7

+ 

+ .fi

+ .RE

+ 

+ .PP

  You can also set the following mount points by passing the \fB\fC\-v /host:/container\fR flag to Docker.

  

  .PP

@@ -23,6 +23,7 @@ 

  mkdir -p ${HTTPD_CONFIGURATION_PATH}

  chmod -R a+rwx ${HTTPD_MAIN_CONF_PATH}

  chmod -R a+rwx ${HTTPD_MAIN_CONF_D_PATH}

+ chmod -R a+rwx ${HTTPD_MAIN_CONF_MODULES_D_PATH}

  chmod -R a+r   /etc/pki/tls/certs/localhost.crt

  chmod -R a+r   /etc/pki/tls/private/localhost.key

  mkdir -p ${HTTPD_APP_ROOT}/etc

@@ -80,6 +80,8 @@ 

  **`HTTPD_LOG_TO_VOLUME`**  

         By default, httpd logs into standard output, so the logs are accessible by using the docker logs command. When `HTTPD_LOG_TO_VOLUME` is set, httpd logs into `/var/log/httpd24`, which can be mounted to host system using the container volumes. This option is only allowed when container is run as UID 0.

  

+ **`HTTPD_MPM`**

+        The variable `HTTPD_MPM` can be set to change the default Multi-Processing Module (MPM) from the package default MPM.

  

  

  If you want to run the image and mount the log files into `/wwwlogs` on the host
@@ -89,6 +91,12 @@ 

  $ docker run -d -u 0 -e HTTPD_LOG_TO_VOLUME=1 --name httpd -v /wwwlogs:/var/log/httpd24:Z rhscl/httpd-24-rhel7

  ```

  

+ To run an image using the `event` MPM (rather than the default `prefork`), execute the following command:

+ 

+ ```

+ $ docker run -d -e HTTPD_MPM=event --name httpd rhscl/httpd-24-rhel7

+ ```

+ 

  You can also set the following mount points by passing the `-v /host:/container` flag to Docker.

  

  **`/var/www`**  

@@ -23,6 +23,8 @@ 

    chmod 755 ${HTTPD_MAIN_CONF_PATH} && \

    chmod 644 ${HTTPD_MAIN_CONF_D_PATH}/* && \

    chmod 755 ${HTTPD_MAIN_CONF_D_PATH} && \

+   chmod 644 ${HTTPD_MAIN_CONF_MODULES_D_PATH}/* && \

+   chmod 755 ${HTTPD_MAIN_CONF_MODULES_D_PATH} && \

    chmod 600 /etc/pki/tls/certs/localhost.crt && \

    chmod 600 /etc/pki/tls/private/localhost.key && \

    chmod 710 ${HTTPD_VAR_RUN}
@@ -49,6 +51,15 @@ 

    fi

  }

  

+ config_mpm() {

+   if [ -v HTTPD_MPM -a -f ${HTTPD_MAIN_CONF_MODULES_D_PATH}/00-mpm.conf ]; then

+     local mpmconf=${HTTPD_MAIN_CONF_MODULES_D_PATH}/00-mpm.conf

+     sed -i -e 's,^LoadModule,#LoadModule,' ${mpmconf}

+     sed -i -e "/LoadModule mpm_${HTTPD_MPM}/s,^#LoadModule,LoadModule," ${mpmconf}

+     echo "---> Set MPM to ${HTTPD_MPM} in ${mpmconf}"

+   fi

+ }

+ 

  # get_matched_files finds file for image extending

  function get_matched_files() {

    local custom_dir default_dir
@@ -114,8 +125,11 @@ 

  process_ssl_certs() {

    local dir=${1:-.}

    if [ -d ${dir}/httpd-ssl/private ] && [ -d ${dir}/httpd-ssl/certs ]; then

+     echo "---> Moving the httpd-ssl directory included in the source to a directory that isn't exposed by httpd..."

+     mv ${dir}/httpd-ssl ${HTTPD_APP_ROOT}

+   fi

+   if [ -d ${HTTPD_APP_ROOT}/httpd-ssl/private ] && [ -d ${HTTPD_APP_ROOT}/httpd-ssl/certs ]; then

      echo "---> Looking for SSL certs for httpd..."

-     cp -r ${dir}/httpd-ssl ${HTTPD_APP_ROOT}

      local ssl_cert="$(ls -A ${HTTPD_APP_ROOT}/httpd-ssl/certs/*.pem | head -n 1)"

      local ssl_private="$(ls -A ${HTTPD_APP_ROOT}/httpd-ssl/private/*.pem | head -n 1)"

      if [ -f "${ssl_cert}" ] ; then
@@ -130,7 +144,6 @@ 

          sed -i '/^SSLCertificateKeyFile .*/d'  ${HTTPD_MAIN_CONF_D_PATH}/ssl.conf

        fi

      fi

-     rm -rf ${dir}/httpd-ssl

    fi

  }

  

@@ -0,0 +1,3 @@ 

+ source ${HTTPD_CONTAINER_SCRIPTS_PATH}/common.sh

+ 

+ config_mpm

file modified
+102 -4
@@ -295,7 +295,7 @@ 

  #                        use "true" for allow remote access to the web-UI,

  #                        "false" is default

  # Arguments: cluster_version - version of the OpenShift cluster to use, empty

- #                              means default version of `oc`; example value: v3.7.0;

+ #                              means default version of `oc`; example value: 3.7;

  #                              also can be specified outside by OC_CLUSTER_VERSION

  function ct_os_cluster_up() {

    ct_os_cluster_running && echo "Cluster already running. Nothing is done." && return 0
@@ -316,10 +316,25 @@ 

    local cluster_ip="127.0.0.1"

    [ "${is_public}" == "true" ] && cluster_ip=$(ct_get_public_ip)

  

+   if [ -n "${cluster_version}" ] ; then

+     # if $cluster_version is not set, we simply use oc that is available

+     ct_os_set_path_oc "${cluster_version}"

+   fi

+ 

    mkdir -p ${dir}/{config,data,pv}

-   oc cluster up --host-data-dir=${dir}/data --host-config-dir=${dir}/config \

-                 --host-pv-dir=${dir}/pv --use-existing-config --public-hostname=${cluster_ip} \

-                 ${cluster_version:+--version=$cluster_version }

+   case $(oc version| head -n 1) in

+     "oc v3.1"?.*)

+       oc cluster up --base-dir="${dir}/data" --public-hostname="${cluster_ip}"

+       ;;

+     "oc v3."*)

+       oc cluster up --host-data-dir="${dir}/data" --host-config-dir="${dir}/config" \

+                     --host-pv-dir="${dir}/pv" --use-existing-config --public-hostname="${cluster_ip}"

+       ;;

+     *)

+       echo "ERROR: Unexpected oc version." >&2

+       return 1

+       ;;

+   esac

    oc version

    oc login -u system:admin

    oc project default
@@ -344,6 +359,89 @@ 

    oc cluster status &>/dev/null

  }

  

+ # ct_os_set_path_oc OC_VERSION

+ # --------------------

+ # This is a trick that helps using correct version of the `oc`:

+ # The input is version of the openshift in format v3.6.0 etc.

+ # If the currently available version of oc is not of this version,

+ # it first takes a look into /usr/local/oc-<ver>/bin directory,

+ # and if not found there it downloads the community release from github.

+ # In the end the PATH variable is changed, so the other tests can still use just 'oc'.

+ # Arguments: oc_version - X.Y part of the version of OSE (e.g. 3.9)

+ function ct_os_set_path_oc() {

+   local oc_version=$(ct_os_get_latest_ver $1)

+   local oc_path

+ 

+   if oc version | grep -q "oc ${oc_version%.*}." ; then

+     echo "Binary oc found already available in version ${oc_version}: `which oc` Doing noting."

+     return 0

+   fi

+ 

+   # first check whether we already have oc available in /usr/local

+   local installed_oc_path="/usr/local/oc-${oc_version%.*}/bin"

+ 

+   if [ -x "${installed_oc_path}/oc" ] ; then

+     oc_path="${installed_oc_path}"

+     echo "Binary oc found in ${installed_oc_path}" >&2

+   else

+     # oc not available in /usr/local, try to download it from github (community release)

+     oc_path="/tmp/oc-${oc_version}-bin"

+     ct_os_download_upstream_oc "${oc_version}" "${oc_path}"

+   fi

+   if [ -z "${oc_path}/oc" ] ; then

+     echo "ERROR: oc not found installed, nor downloaded" >&1

+     return 1

+   fi

+   export PATH="${oc_path}:${PATH}"

+   if ! oc version | grep -q "oc ${oc_version%.*}." ; then

+     echo "ERROR: something went wrong, oc located at ${oc_path}, but oc of version ${oc_version} not found in PATH ($PATH)" >&1

+     return 1

+   else

+     echo "PATH set correctly, binary oc found in version ${oc_version}: `which oc`"

+   fi

+ }

+ 

+ # ct_os_get_latest_ver VERSION_PART_X

+ # --------------------

+ # Returns full version (vX.Y.Z) from part of the version (X.Y)

+ # Arguments: vxy - X.Y part of the version

+ # Returns vX.Y.Z variant of the version

+ function ct_os_get_latest_ver(){

+   local vxy="v$1"

+   for vz in {3..0} ; do

+     curl -sif "https://github.com/openshift/origin/releases/tag/${vxy}.${vz}" >/dev/null && echo "${vxy}.${vz}" && return 0

+   done

+   echo "ERROR: version ${vxy} not found in https://github.com/openshift/origin/tags" >&2

+   return 1

+ }

+ 

+ # ct_os_download_upstream_oc OC_VERSION OUTPUT_DIR

+ # --------------------

+ # Downloads a particular version of openshift-origin-client-tools from

+ # github into specified output directory

+ # Arguments: oc_version - version of OSE (e.g. v3.7.2)

+ # Arguments: output_dir - output directory

+ function ct_os_download_upstream_oc() {

+   local oc_version=$1

+   local output_dir=$2

+ 

+   # check whether we already have the binary in place

+   [ -x "${output_dir}/oc" ] && return 0

+ 

+   mkdir -p "${output_dir}"

+   # using html output instead of https://api.github.com/repos/openshift/origin/releases/tags/${oc_version},

+   # because API is limited for number of queries if not authenticated

+   tarball=$(curl -si "https://github.com/openshift/origin/releases/tag/${oc_version}" | grep -o -e "openshift-origin-client-tools-${oc_version}-[a-f0-9]*-linux-64bit.tar.gz" | head -n 1)

+ 

+   # download, unpack the binaries and then put them into output directory

+   echo "Downloading https://github.com/openshift/origin/releases/download/${oc_version}/${tarball} into ${output_dir}/" >&2

+   curl -sL https://github.com/openshift/origin/releases/download/${oc_version}/"${tarball}" | tar -C "${output_dir}" -xz

+   mv -f "${output_dir}"/"${tarball%.tar.gz}"/* "${output_dir}/"

+ 

+   rmdir "${output_dir}"/"${tarball%.tar.gz}"

+ }

+ 

+ 

  # ct_os_test_s2i_app_func IMAGE APP CONTEXT_DIR CHECK_CMD [OC_ARGS]

  # --------------------

  # Runs [image] and [app] in the openshift and optionally specifies env_params

file modified
+23
@@ -208,6 +208,29 @@ 

  }

  

  

+ # ct_npm_works

+ # --------------------

+ # Checks existance of the npm tool and runs it.

+ function ct_npm_works() {

+   local tmpdir=$(mktemp -d)

+   : "  Testing npm in the container image"

+   docker run --rm ${IMAGE_NAME} /bin/bash -c "npm --version" >${tmpdir}/version

+ 

+   if [ $? -ne 0 ] ; then

+     echo "ERROR: 'npm --version' does not work inside the image ${IMAGE_NAME}." >&2

+     return 1

+   fi

+ 

+   docker run --rm ${IMAGE_NAME} /bin/bash -c "npm install jquery && test -f node_modules/jquery/src/jquery.js"

+   if [ $? -ne 0 ] ; then

+     echo "ERROR: npm could not install jquery inside the image ${IMAGE_NAME}." >&2

+     return 1

+   fi

+ 

+   : "  Success!"

+ }

+ 

+ 

  # ct_path_append PATH_VARNAME DIRECTORY

  # -------------------------------------

  # Append DIRECTORY to VARIABLE of name PATH_VARNAME, the VARIABLE must consist