Skip to content

Commit

Permalink
initial create
Browse files Browse the repository at this point in the history
  • Loading branch information
bparees committed Apr 28, 2015
1 parent 2a1b86e commit 66a34ec
Show file tree
Hide file tree
Showing 17 changed files with 2,568 additions and 0 deletions.
28 changes: 28 additions & 0 deletions 5.5/.sti/bin/assemble
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

source ./.bashrc

set -e

echo "---> Installing application source"
cp -Rf /tmp/src/* ./

if [ -f composer.json ]; then
echo "Installing dependencies from composer.json... "

# Install Composer
php -r "readfile('https://getcomposer.org/installer');" | php

# Install App dependencies using Composer
./composer.phar install --no-interaction --no-ansi --no-scripts --optimize-autoloader

if [ ! -f composer.lock ]; then
echo -e "\nConsider adding a composer.lock file into your source repository\n"
fi
fi


# Symlinking the application into dir from which httpd serves the app.
# NOTE: This is only possible due to the fact the the image is running under root user.
rm -rf /opt/rh/httpd24/root/var/www/html/
ln -s /opt/openshift/src/ /opt/rh/httpd24/root/var/www/html
25 changes: 25 additions & 0 deletions 5.5/.sti/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# For SCL enablement
source ./.bashrc

# Default php.ini configuration values, all taken
# from php defaults.
export ERROR_REPORTING=${ERROR_REPORTING:-E_ALL & ~E_NOTICE}
export DISPLAY_ERRORS=${DISPLAY_ERRORS:-ON}
export DISPLAY_STARTUP_ERRORS=${DISPLAY_STARTUP_ERRORS:-OFF}
export TRACK_ERRORS=${TRACK_ERRORS:-OFF}
export HTML_ERRORS=${HTML_ERRORS:-ON}
export INCLUDE_PATH=${INCLUDE_PATH:-.:/opt/openshift/src:/opt/rh/php55/root/usr/share/pear}
export SESSION_PATH=${SESSION_PATH:-/tmp/sessions}
# TODO should be dynamically calculated based on container memory limit/16
export OPCACHE_MEMORY_CONSUMPTION=${OPCACHE_MEMORY_CONSUMPTION:-16M}

export PHPRC=/opt/openshift/etc
export PHP_INI_SCAN_DIR=/opt/openshift/etc/php.d

envsubst < /opt/openshift/etc/php.ini.template > /opt/rh/php55/root/etc/php.ini
envsubst < /opt/openshift/etc/php.d/opcache.ini.template > /opt/rh/php55/root/etc/php.d/opcache.ini

set -e
exec httpd -C 'Include /opt/openshift/httpd.conf' -D FOREGROUND
18 changes: 18 additions & 0 deletions 5.5/.sti/bin/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
#
# Default STI usage script for the php-5.0 image.
#

DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'`

cat <<EOF
This is a STI PHP-5.5 ${DISTRO} base image:
To use it, install STI: https://github.com/openshift/source-to-image
Sample invocation:
sti build https://github.com/openshift/sti-php.git --contextDir=/5.5/test/test-app/ openshift/php-55-${DISTRO}7 php-test-app
You can then run the resulting image via:
docker run -p 8080:8080 php-test-app
EOF
43 changes: 43 additions & 0 deletions 5.5/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM openshift/base-centos7

# This image provides an Apache+PHP environment for running PHP
# applications.

MAINTAINER Ben Parees <bparees@redhat.com>

# Image metadata
ENV PHP_VERSION 5.5
ENV IMAGE_DESCRIPTION PHP 5.5
ENV IMAGE_TAGS php,php55
ENV IMAGE_EXPOSE_SERVICES 8080:http
#ENV PHPRC /opt/openshift/etc/php.ini
#ENV PHP_INI_SCAN_DIR /opt/openshift/etc/php.d

# Install Apache httpd and PHP
RUN yum install -y \
https://www.softwarecollections.org/en/scls/rhscl/httpd24/epel-7-x86_64/download/rhscl-httpd24-epel-7-x86_64.noarch.rpm \
https://www.softwarecollections.org/en/scls/rhscl/php55/epel-7-x86_64/download/rhscl-php55-epel-7-x86_64.noarch.rpm \
https://www.softwarecollections.org/en/scls/remi/php55more/epel-7-x86_64/download/remi-php55more-epel-7-x86_64.noarch.rpm && \
yum install -y --setopt=tsflags=nodocs httpd24 php55 php55-php php55-php-mysqlnd php55-php-pgsql php55-php-bcmath php55-php-devel \
php55-php-fpm php55-php-gd php55-php-intl php55-php-ldap php55-php-mbstring php55-php-mcript php55-php-pdo \
php55-php-pecl-memcache php55-php-process php55-php-soap php55-php-opcache php55-php-xml \
php55-php-pecl-imagick php55-php-pecl-xdebug && \
yum clean all -y && \
mkdir /tmp/sessions

ENV PATH $PATH:/opt/rh/php55/root/usr/bin

USER root

EXPOSE 8080

# Copy the STI scripts from the specific language image to /usr/local/sti
COPY ./.sti/bin/ /usr/local/sti

# Each language image can have 'contrib' a directory with extra files needed to
# run and build the applications.
COPY ./contrib/ /opt/openshift
RUN chown -R default:default /opt/openshift /tmp/sessions

# Set the default CMD to print the usage of the language image
CMD ["usage"]
42 changes: 42 additions & 0 deletions 5.5/Dockerfile.rhel7
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM openshift/base-rhel7

# This image provides an Apache+PHP environment for running PHP
# applications.

MAINTAINER Ben Parees <bparees@redhat.com>

# Image metadata
ENV PHP_VERSION 5.5
ENV IMAGE_DESCRIPTION PHP 5.5
ENV IMAGE_TAGS php,php55
ENV IMAGE_EXPOSE_SERVICES 8080:http
#ENV PHPRC /opt/openshift/etc/php.ini
#ENV PHP_INI_SCAN_DIR /opt/openshift/etc/php.d

RUN yum-config-manager --enable rhel-server-rhscl-7-rpms && \
yum-config-manager --enable rhel-7-server-optional-rpms && \
yum install -y \
https://www.softwarecollections.org/en/scls/remi/php55more/epel-7-x86_64/download/remi-php55more-epel-7-x86_64.noarch.rpm && \
yum install -y --setopt=tsflags=nodocs httpd24 php55 php55-php php55-php-mysqlnd php55-php-pgsql php55-php-bcmath php55-php-devel \
php55-php-fpm php55-php-gd php55-php-intl php55-php-ldap php55-php-mbstring php55-php-mcript php55-php-pdo \
php55-php-pecl-memcache php55-php-process php55-php-soap php55-php-opcache php55-php-xml \
php55-php-pecl-imagick php55-php-pecl-xdebug && \
yum clean all -y && \
mkdir /tmp/sessions

ENV PATH $PATH:/opt/rh/php55/root/usr/bin

USER root

EXPOSE 8080

# Copy the STI scripts from the specific language image to /usr/local/sti
COPY ./.sti/bin/ /usr/local/sti

# Each language image can have 'contrib' a directory with extra files needed to
# run and build the applications.
COPY ./contrib/ /opt/openshift
RUN chown -R default:default /opt/openshift /tmp/sessions

# Set the default CMD to print the usage of the language image
CMD ["usage"]
1 change: 1 addition & 0 deletions 5.5/README.md
95 changes: 95 additions & 0 deletions 5.5/contrib/etc/php.d/opcache.ini.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
; Enable Zend OPcache extension module
zend_extension=/opt/rh/php54/root/usr/lib64/php/modules/opcache.so

; Determines if Zend OPCache is enabled
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0

; The OPcache shared memory storage size.
opcache.memory_consumption=${OPCACHE_MEMORY_CONSUMPTION}

; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 100000 are allowed.
opcache.max_accelerated_files=4000

; The maximum percentage of "wasted" memory until a restart is scheduled.
;opcache.max_wasted_percentage=5

; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
; files with the same name (basename). Disabling the directive improves
; performance, but may break existing applications.
;opcache.use_cwd=1

; When disabled, you must reset the OPcache manually or restart the
; webserver for changes to the filesystem to take effect.
;opcache.validate_timestamps=1

; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. ("1" means validate once per second, but only
; once per request. "0" means always validate)
;opcache.revalidate_freq=2

; Enables or disables file search in include_path optimization
;opcache.revalidate_path=0

; If disabled, all PHPDoc comments are dropped from the code to reduce the
;size of the optimized code.
;opcache.save_comments=1

; If disabled, PHPDoc comments are not loaded from SHM, so "Doc Comments"
; may be always stored (save_comments=1), but not loaded by applications
; that don't need them anyway.
;opcache.load_comments=1

; If enabled, a fast shutdown sequence is used for the accelerated code
opcache.fast_shutdown=1

; Allow file existence override (file_exists, etc.) performance feature.
;opcache.enable_file_override=0

; A bitmask, where each bit enables or disables the appropriate OPcache
; passes
;opcache.optimization_level=0xffffffff

;opcache.inherited_hack=1
;opcache.dups_fix=0

; The location of the OPcache blacklist file (wildcards allowed).
; Each OPcache blacklist file is a text file that holds the names of files
; that should not be accelerated.
opcache.blacklist_filename=/opt/rh/php54/root/etc/php.d/opcache*.blacklist

; Allows exclusion of large files from being cached. By default all files
; are cached.
opcache.max_file_size=1M

; Check the cache checksum each N requests.
; The default value of "0" means that the checks are disabled.
;opcache.consistency_checks=0

; How long to wait (in seconds) for a scheduled restart to begin if the cache
; is not being accessed.
;opcache.force_restart_timeout=180

; OPcache error_log file name. Empty string assumes "stderr".
;opcache.error_log=

; All OPcache errors go to the Web server log.
; By default, only fatal errors (level 0) or errors (level 1) are logged.
; You can also enable warnings (level 2), info messages (level 3) or
; debug messages (level 4).
;opcache.log_verbosity_level=1

; Preferred Shared Memory back-end. Leave empty and let the system decide.
;opcache.preferred_memory_model=

; Protect the shared memory from unexpected writing during script execution.
; Useful for internal debugging only.
;opcache.protect_memory=0

Loading

0 comments on commit 66a34ec

Please sign in to comment.