Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b500fdddb2 | ||
|
|
c08abcc5ab |
22 changed files with 1 additions and 3637 deletions
0
.gitignore
vendored
0
.gitignore
vendored
|
|
@ -1,29 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
shopt -s dotglob
|
|
||||||
echo "---> Installing application source..."
|
|
||||||
mv /tmp/src/* ./
|
|
||||||
|
|
||||||
if [ -f composer.json ]; then
|
|
||||||
echo "Found 'composer.json', installing dependencies using composer.phar... "
|
|
||||||
|
|
||||||
# Install Composer
|
|
||||||
curl https://getcomposer.org/installer | php
|
|
||||||
|
|
||||||
# Change the repo mirror if provided
|
|
||||||
if [ -n "$COMPOSER_MIRROR" ]; then
|
|
||||||
./composer.phar config -g repositories.packagist composer $COMPOSER_MIRROR
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install App dependencies using Composer
|
|
||||||
./composer.phar install --no-interaction --no-ansi --optimize-autoloader
|
|
||||||
|
|
||||||
if [ ! -f composer.lock ]; then
|
|
||||||
echo -e "\nConsider adding a 'composer.lock' file into your source repository.\n"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fix source directory permissions
|
|
||||||
fix-permissions ./
|
|
||||||
48
.s2i/bin/run
48
.s2i/bin/run
|
|
@ -1,48 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
export_vars=$(cgroup-limits); export $export_vars
|
|
||||||
export DOCUMENTROOT=${DOCUMENTROOT:-/}
|
|
||||||
|
|
||||||
# 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/app-root/src:/usr/share/pear}
|
|
||||||
export SESSION_PATH=${SESSION_PATH:-/tmp/sessions}
|
|
||||||
export SHORT_OPEN_TAG=${SHORT_OPEN_TAG:-OFF}
|
|
||||||
# TODO should be dynamically calculated based on container memory limit/16
|
|
||||||
export OPCACHE_MEMORY_CONSUMPTION=${OPCACHE_MEMORY_CONSUMPTION:-128}
|
|
||||||
|
|
||||||
export OPCACHE_REVALIDATE_FREQ=${OPCACHE_REVALIDATE_FREQ:-2}
|
|
||||||
|
|
||||||
export PHPRC=${PHPRC:-/etc/php.ini}
|
|
||||||
export PHP_INI_SCAN_DIR=${PHP_INI_SCAN_DIR:-/etc/php.d}
|
|
||||||
|
|
||||||
envsubst < /opt/app-root/etc/php.ini.template > /etc/php.ini
|
|
||||||
envsubst < /opt/app-root/etc/php.d/10-opcache.ini.template > /etc/php.d/10-opcache.ini
|
|
||||||
|
|
||||||
export HTTPD_START_SERVERS=${HTTPD_START_SERVERS:-8}
|
|
||||||
export HTTPD_MAX_SPARE_SERVERS=$((HTTPD_START_SERVERS+10))
|
|
||||||
|
|
||||||
if [ -n "${NO_MEMORY_LIMIT:-}" -o -z "${MEMORY_LIMIT_IN_BYTES:-}" ]; then
|
|
||||||
#
|
|
||||||
export HTTPD_MAX_REQUEST_WORKERS=${HTTPD_MAX_REQUEST_WORKERS:-256}
|
|
||||||
else
|
|
||||||
# A simple calculation for MaxRequestWorkers would be: Total Memory / Size Per Apache process.
|
|
||||||
# The total memory is determined from the Cgroups and the average size for the
|
|
||||||
# Apache process is estimated to 15MB.
|
|
||||||
max_clients_computed=$((MEMORY_LIMIT_IN_BYTES/1024/1024/15))
|
|
||||||
# The MaxClients should never be lower than StartServers, which is set to 5.
|
|
||||||
# In case the container has memory limit set to <64M we pin the MaxClients to 4.
|
|
||||||
[[ $max_clients_computed -le 4 ]] && max_clients_computed=4
|
|
||||||
export HTTPD_MAX_REQUEST_WORKERS=${HTTPD_MAX_REQUEST_WORKERS:-$max_clients_computed}
|
|
||||||
echo "-> Cgroups memory limit is set, using HTTPD_MAX_REQUEST_WORKERS=${HTTPD_MAX_REQUEST_WORKERS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
envsubst < /opt/app-root/etc/conf.d/50-mpm-tuning.conf.template > /opt/app-root/etc/conf.d/50-mpm-tuning.conf
|
|
||||||
envsubst < /opt/app-root/etc/conf.d/00-documentroot.conf.template > /opt/app-root/etc/conf.d/00-documentroot.conf
|
|
||||||
|
|
||||||
exec httpd -D FOREGROUND
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
cat <<EOF
|
|
||||||
This is the php S2I image:
|
|
||||||
To use it, install S2I: https://github.com/openshift/source-to-image
|
|
||||||
|
|
||||||
Sample invocation:
|
|
||||||
|
|
||||||
s2i build <source code path/URL> php <application image>
|
|
||||||
|
|
||||||
You can then run the resulting image via:
|
|
||||||
docker run <application image>
|
|
||||||
EOF
|
|
||||||
84
Dockerfile
84
Dockerfile
|
|
@ -1,84 +0,0 @@
|
||||||
FROM registry.fedoraproject.org/fedora:26
|
|
||||||
|
|
||||||
# Description
|
|
||||||
# This image provides an Apache 2.4 + PHP 7.0 environment for running PHP applications.
|
|
||||||
# Exposed ports:
|
|
||||||
# * 8080 - alternative port for http
|
|
||||||
# Additional packages
|
|
||||||
# * git, zip, unzip are needed for composer
|
|
||||||
# * gettext is needed for `envsubst` command used by scripts
|
|
||||||
# * findutils for fixing permissions
|
|
||||||
# * python for cgroup limits helper script
|
|
||||||
|
|
||||||
LABEL MAINTAINER Rado Pitonak <rpitonak@redhat.com>
|
|
||||||
|
|
||||||
RUN dnf install -y --setopt=tsflags=nodocs php php-opcache && \
|
|
||||||
dnf install -y --setopt=tsflags=nodocs httpd && \
|
|
||||||
dnf install -y --setopt=tsflags=nodocs git gettext zip unzip findutils python && \
|
|
||||||
dnf -y clean all
|
|
||||||
|
|
||||||
ENV PHP_VERSION=7.0 \
|
|
||||||
NAME=php\
|
|
||||||
VERSION=0 \
|
|
||||||
RELEASE=1 \
|
|
||||||
ARCH=x86_64
|
|
||||||
|
|
||||||
ENV HOME=/opt/app-root
|
|
||||||
|
|
||||||
LABEL summary="php runtime" \
|
|
||||||
name="$FGC/$NAME" \
|
|
||||||
version="$VERSION" \
|
|
||||||
release="$RELEASE.$DISTTAG" \
|
|
||||||
architecture="$ARCH" \
|
|
||||||
description="Platform for building and running PHP 7.0 applications." \
|
|
||||||
vendor="Fedora Project" \
|
|
||||||
com.redhat.component="$NAME" \
|
|
||||||
usage="s2i build <SOURCE-REPOSITORY> php <APP-NAME>" \
|
|
||||||
org.fedoraproject.component="php" \
|
|
||||||
authoritative-source-url="registry.fedoraproject.org" \
|
|
||||||
io.k8s.description="Platform for building and running PHP 7.0 applications." \
|
|
||||||
io.k8s.display-name="Apache 2.4 with PHP 7.0" \
|
|
||||||
io.openshift.tags="builder,php,php70" \
|
|
||||||
io.openshift.expose-services="8080:https" \
|
|
||||||
io.openshift.s2i.scripts-url="image:///usr/local/s2i"
|
|
||||||
|
|
||||||
# S2I scripts
|
|
||||||
COPY ./.s2i/bin/ /usr/local/s2i
|
|
||||||
|
|
||||||
# Copy executable utilities.
|
|
||||||
COPY bin/ /usr/bin/
|
|
||||||
|
|
||||||
# Each language image can have 'contrib' a directory with extra files needed to
|
|
||||||
# run and build the applications.
|
|
||||||
COPY ./contrib/ /opt/app-root
|
|
||||||
|
|
||||||
# Add help file
|
|
||||||
COPY root /
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
RUN mkdir -p ${HOME} && \
|
|
||||||
useradd -u 1001 -r -g 0 -d ${HOME} -s /sbin/nologin \
|
|
||||||
-c "Default user" default
|
|
||||||
|
|
||||||
# In order to drop the root user, we have to make some directories world
|
|
||||||
# writeable as OpenShift default security model is to run the container under
|
|
||||||
# random UID.
|
|
||||||
RUN mkdir -p ${HOME}/src && \
|
|
||||||
sed -i -f /opt/app-root/etc/httpdconf.sed /etc/httpd/conf/httpd.conf && \
|
|
||||||
head -n151 /etc/httpd/conf/httpd.conf | tail -n1 | grep "AllowOverride All" || exit && \
|
|
||||||
echo "IncludeOptional /opt/app-root/etc/conf.d/*.conf" >> /etc/httpd/conf/httpd.conf && \
|
|
||||||
mkdir /tmp/sessions && \
|
|
||||||
chown -R 1001:0 /opt/app-root /tmp/sessions && \
|
|
||||||
chmod -R a+rwx /tmp/sessions && \
|
|
||||||
chmod -R ug+rwx /opt/app-root && \
|
|
||||||
chmod -R a+rwx /etc/php.d && \
|
|
||||||
chmod -R a+rwx /etc/php.ini && \
|
|
||||||
chmod -R a+rwx /run/httpd
|
|
||||||
|
|
||||||
USER 1001
|
|
||||||
|
|
||||||
WORKDIR ${HOME}/src
|
|
||||||
|
|
||||||
# Command which will start service during command `docker run`
|
|
||||||
CMD /usr/local/s2i/usage
|
|
||||||
674
LICENSE
674
LICENSE
|
|
@ -1,674 +0,0 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
{one line to give the program's name and a brief idea of what it does.}
|
|
||||||
Copyright (C) {year} {name of author}
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
{project} Copyright (C) {year} {fullname}
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
||||||
15
Makefile
15
Makefile
|
|
@ -1,15 +0,0 @@
|
||||||
.PHONY: build run test build-test
|
|
||||||
|
|
||||||
IMAGE_NAME=php
|
|
||||||
|
|
||||||
build:
|
|
||||||
docker build --tag=$(IMAGE_NAME) .
|
|
||||||
|
|
||||||
run: build
|
|
||||||
docker run -d -p 8080:8080 $(IMAGE_NAME)
|
|
||||||
|
|
||||||
build-test:
|
|
||||||
docker build --tag=$(IMAGE_NAME)-candidate .
|
|
||||||
|
|
||||||
test: build-test
|
|
||||||
./test/run
|
|
||||||
253
README.md
253
README.md
|
|
@ -1,253 +0,0 @@
|
||||||
PHP Source to image builder
|
|
||||||
============================
|
|
||||||
|
|
||||||
This repository contains the source for building various versions of
|
|
||||||
the PHP application as a reproducible Docker image using
|
|
||||||
[source-to-image](https://github.com/openshift/source-to-image).
|
|
||||||
This image is port to **fedora** of Software collections [php7.0 s2i](https://github.com/sclorg/s2i-php-container/tree/master/7.0).
|
|
||||||
The resulting image can be run using [Docker](http://docker.io).
|
|
||||||
|
|
||||||
Build
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
Most simple way to build image is using **Makefile**.
|
|
||||||
```
|
|
||||||
$ make build
|
|
||||||
```
|
|
||||||
|
|
||||||
This build php image and tag it with name and version specified in **Makefile**:
|
|
||||||
```
|
|
||||||
IMAGE_NAME=php
|
|
||||||
VERSION=7
|
|
||||||
```
|
|
||||||
|
|
||||||
Usage
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
Build your PHP application
|
|
||||||
```
|
|
||||||
s2i build <SOURCE-REPOSITORY> php <NAME-OF-APP>
|
|
||||||
```
|
|
||||||
Substitute <SOURCE-REPOSITORY> with path to your application or link to GitHub repository.
|
|
||||||
For example:
|
|
||||||
```
|
|
||||||
s2i build https://github.com/fermayo/hello-world-php php hello-world
|
|
||||||
```
|
|
||||||
|
|
||||||
Then run application in docker container:
|
|
||||||
```
|
|
||||||
docker run -p 8080:8080 <NAME-OF-APP>
|
|
||||||
```
|
|
||||||
|
|
||||||
So for our example it would be:
|
|
||||||
```
|
|
||||||
docker run -p 8080:8080 hello-world
|
|
||||||
```
|
|
||||||
|
|
||||||
**Accessing the application:**
|
|
||||||
```
|
|
||||||
curl 127.0.0.1:8080
|
|
||||||
```
|
|
||||||
Repository organization
|
|
||||||
------------------------
|
|
||||||
* **php**
|
|
||||||
|
|
||||||
* **Dockerfile**
|
|
||||||
|
|
||||||
Fedora based Dockerfile.
|
|
||||||
|
|
||||||
* **Makefile**
|
|
||||||
|
|
||||||
Used to build and run docker image.
|
|
||||||
|
|
||||||
* **openshift-template.yaml**
|
|
||||||
|
|
||||||
Template to build and run PHP applications easily in OpenShift.
|
|
||||||
|
|
||||||
* **`.s2i/bin/`**
|
|
||||||
|
|
||||||
This folder contains scripts that are run by [S2I](https://github.com/openshift/source-to-image):
|
|
||||||
|
|
||||||
* **assemble**
|
|
||||||
|
|
||||||
Used to install the sources into the location where the application
|
|
||||||
will be run and prepare the application for deployment (eg. installing
|
|
||||||
modules using npm, etc..)
|
|
||||||
|
|
||||||
* **run**
|
|
||||||
|
|
||||||
This script is responsible for running the application, by using the
|
|
||||||
application web server.
|
|
||||||
* **usage**
|
|
||||||
|
|
||||||
This script is called when someone try to run image using docker.
|
|
||||||
|
|
||||||
* **`bin/`**
|
|
||||||
|
|
||||||
Helper scripts for fixing permissions and reading limits from cgroup system.
|
|
||||||
|
|
||||||
* **`contrib/`**
|
|
||||||
|
|
||||||
This folder contains a file with commonly used modules.
|
|
||||||
|
|
||||||
* **`root/`**
|
|
||||||
|
|
||||||
Manual pages.
|
|
||||||
|
|
||||||
* **`test/`**
|
|
||||||
|
|
||||||
This folder contains the [S2I](https://github.com/openshift/source-to-image)
|
|
||||||
test framework with a sample PHP app.
|
|
||||||
|
|
||||||
* **`test-app/`**
|
|
||||||
|
|
||||||
A simple PHP app used for testing purposes by the [S2I](https://github.com/openshift/source-to-image) test framework.
|
|
||||||
|
|
||||||
* **run**
|
|
||||||
|
|
||||||
Script that runs the [S2I](https://github.com/openshift/source-to-image) test framework.
|
|
||||||
|
|
||||||
|
|
||||||
Environment variables
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
To set these environment variables, you can place them as a key value pair into a `.sti/environment`
|
|
||||||
file inside your source code repository.
|
|
||||||
|
|
||||||
The following environment variables set their equivalent property value in the php.ini file:
|
|
||||||
* **ERROR_REPORTING**
|
|
||||||
* Informs PHP of which errors, warnings and notices you would like it to take action for
|
|
||||||
* Default: E_ALL & ~E_NOTICE
|
|
||||||
* **DISPLAY_ERRORS**
|
|
||||||
* Controls whether or not and where PHP will output errors, notices and warnings
|
|
||||||
* Default: ON
|
|
||||||
* **DISPLAY_STARTUP_ERRORS**
|
|
||||||
* Cause display errors which occur during PHP's startup sequence to be handled separately from display errors
|
|
||||||
* Default: OFF
|
|
||||||
* **TRACK_ERRORS**
|
|
||||||
* Store the last error/warning message in $php_errormsg (boolean)
|
|
||||||
* Default: OFF
|
|
||||||
* **HTML_ERRORS**
|
|
||||||
* Link errors to documentation related to the error
|
|
||||||
* Default: ON
|
|
||||||
* **INCLUDE_PATH**
|
|
||||||
* Path for PHP source files
|
|
||||||
* Default: .:/opt/app-root/src:/usr/share/pear
|
|
||||||
* **SESSION_PATH**
|
|
||||||
* Location for session data files
|
|
||||||
* Default: /tmp/sessions
|
|
||||||
* **SHORT_OPEN_TAG**
|
|
||||||
* Determines whether or not PHP will recognize code between <? and ?> tags
|
|
||||||
* Default: OFF
|
|
||||||
* **DOCUMENTROOT**
|
|
||||||
* Path that defines the DocumentRoot for your application (ie. /public)
|
|
||||||
* Default: /
|
|
||||||
|
|
||||||
The following environment variables set their equivalent property value in the opcache.ini file:
|
|
||||||
* **OPCACHE_MEMORY_CONSUMPTION**
|
|
||||||
* The OPcache shared memory storage size in megabytes
|
|
||||||
* Default: 128
|
|
||||||
* **OPCACHE_REVALIDATE_FREQ**
|
|
||||||
* How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.
|
|
||||||
* Default: 2
|
|
||||||
|
|
||||||
You can also override the entire directory used to load the PHP configuration by setting:
|
|
||||||
* **PHPRC**
|
|
||||||
* Sets the path to the php.ini file
|
|
||||||
* **PHP_INI_SCAN_DIR**
|
|
||||||
* Path to scan for additional ini configuration files
|
|
||||||
|
|
||||||
You can override the Apache [MPM prefork](https://httpd.apache.org/docs/2.4/mod/mpm_common.html)
|
|
||||||
settings to increase the performance for of the PHP application. In case you set
|
|
||||||
the Cgroup limits in Docker, the image will attempt to automatically set the
|
|
||||||
optimal values. You can override this at any time by specifying the values
|
|
||||||
yourself:
|
|
||||||
|
|
||||||
* **HTTPD_START_SERVERS**
|
|
||||||
* The [StartServers](https://httpd.apache.org/docs/2.4/mod/mpm_common.html#startservers)
|
|
||||||
directive sets the number of child server processes created on startup.
|
|
||||||
* Default: 8
|
|
||||||
* **HTTPD_MAX_REQUEST_WORKERS**
|
|
||||||
* The [MaxRequestWorkers](https://httpd.apache.org/docs/2.4/mod/mpm_common.html#maxrequestworkers)
|
|
||||||
directive sets the limit on the number of simultaneous requests that will be served.
|
|
||||||
* `MaxRequestWorkers` was called `MaxClients` before version httpd 2.3.13.
|
|
||||||
* Default: 256 (this is automatically tuned by setting Cgroup limits for the container using this formula:
|
|
||||||
`TOTAL_MEMORY / 15MB`. The 15MB is average size of a single httpd process.
|
|
||||||
|
|
||||||
You can use a custom composer repository mirror URL to download packages instead of the default 'packagist.org':
|
|
||||||
|
|
||||||
* **COMPOSER_MIRROR**
|
|
||||||
* Adds a custom composer repository mirror URL to composer configuration. Note: This only affects packages listed in composer.json.
|
|
||||||
|
|
||||||
Source repository layout
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
You do not need to change anything in your existing PHP project's repository.
|
|
||||||
However, if these files exist they will affect the behavior of the build process:
|
|
||||||
|
|
||||||
* **composer.json**
|
|
||||||
|
|
||||||
List of dependencies to be installed with `composer`. The format is documented
|
|
||||||
[here](https://getcomposer.org/doc/04-schema.md).
|
|
||||||
|
|
||||||
|
|
||||||
* **.htaccess**
|
|
||||||
|
|
||||||
In case the **DocumentRoot** of the application is nested within the source directory `/opt/app-root/src`,
|
|
||||||
users can provide their own Apache **.htaccess** file. This allows the overriding of Apache's behavior and
|
|
||||||
specifies how application requests should be handled. The **.htaccess** file needs to be located at the root
|
|
||||||
of the application source.
|
|
||||||
|
|
||||||
Hot deploy
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
In order to immediately pick up changes made in your application source code, you need to run your built image with the `OPCACHE_REVALIDATE_FREQ=0` environment variable passed to the [Docker](http://docker.io) `-e` run flag:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ docker run -e OPCACHE_REVALIDATE_FREQ=0 -p 8080:8080 php-app
|
|
||||||
```
|
|
||||||
|
|
||||||
To change your source code in running container, use Docker's [exec](http://docker.io) command:
|
|
||||||
```
|
|
||||||
docker exec -it <CONTAINER_ID> /bin/bash
|
|
||||||
```
|
|
||||||
|
|
||||||
After you [Docker exec](http://docker.io) into the running container, your current directory is set
|
|
||||||
to `/opt/app-root/src`, where the source code is located.
|
|
||||||
|
|
||||||
Test
|
|
||||||
---------------------
|
|
||||||
Run:
|
|
||||||
```
|
|
||||||
$ make test
|
|
||||||
```
|
|
||||||
This will build candidate image and check the basic functionality of s2i image.
|
|
||||||
|
|
||||||
Running in OpenShift
|
|
||||||
---------------------
|
|
||||||
Login
|
|
||||||
```
|
|
||||||
$ oc login -u developer
|
|
||||||
```
|
|
||||||
|
|
||||||
Create new project
|
|
||||||
```
|
|
||||||
$ oc new-project sample-project
|
|
||||||
```
|
|
||||||
|
|
||||||
Create template from YAML file
|
|
||||||
```
|
|
||||||
$ oc create -f openshift-template.yaml
|
|
||||||
```
|
|
||||||
|
|
||||||
Create new application (php-fedora is template created in previous step)
|
|
||||||
```
|
|
||||||
$ oc new-app php-fedora -p APP_NAME=<name> -p SOURCE_REPOSITORY=<your-github-repository>
|
|
||||||
```
|
|
||||||
For example:
|
|
||||||
```
|
|
||||||
$ oc new-app php-fedora -p APP_NAME=my-app -p SOURCE_REPOSITORY=https://github.com/fermayo/hello-world-php
|
|
||||||
```
|
|
||||||
Check if everything is ok
|
|
||||||
```
|
|
||||||
$ oc logs -f bc/my-app
|
|
||||||
|
|
@ -1,92 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
"""
|
|
||||||
Script for parsing cgroup information
|
|
||||||
|
|
||||||
This script will read some limits from the cgroup system and parse
|
|
||||||
them, printing out "VARIABLE=VALUE" on each line for every limit that is
|
|
||||||
successfully read. Output of this script can be directly fed into
|
|
||||||
bash's export command. Recommended usage from a bash script:
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
export_vars=$(cgroup-limits) ; export $export_vars
|
|
||||||
|
|
||||||
Variables currently supported:
|
|
||||||
MAX_MEMORY_LIMIT_IN_BYTES
|
|
||||||
Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
|
|
||||||
currently constant value of 9223372036854775807.
|
|
||||||
MEMORY_LIMIT_IN_BYTES
|
|
||||||
Maximum amount of user memory in bytes. If this value is set
|
|
||||||
to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
|
|
||||||
there is no limit set. The value is taken from
|
|
||||||
/sys/fs/cgroup/memory/memory.limit_in_bytes
|
|
||||||
NUMBER_OF_CORES
|
|
||||||
Number of detected CPU cores that can be used. This value is
|
|
||||||
calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
|
|
||||||
NO_MEMORY_LIMIT
|
|
||||||
Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
|
|
||||||
can act as if no memory limit was set. Undefined otherwise.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def _read_file(path):
|
|
||||||
try:
|
|
||||||
with open(path, 'r') as f:
|
|
||||||
return f.read().strip()
|
|
||||||
except IOError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_memory_limit():
|
|
||||||
"""
|
|
||||||
Read memory limit, in bytes.
|
|
||||||
"""
|
|
||||||
|
|
||||||
limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
|
|
||||||
if limit is None or not limit.isdigit():
|
|
||||||
print("Warning: Can't detect memory limit from cgroups",
|
|
||||||
file=sys.stderr)
|
|
||||||
return None
|
|
||||||
return int(limit)
|
|
||||||
|
|
||||||
|
|
||||||
def get_number_of_cores():
|
|
||||||
"""
|
|
||||||
Read number of CPU cores.
|
|
||||||
"""
|
|
||||||
|
|
||||||
core_count = 0
|
|
||||||
|
|
||||||
line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
|
|
||||||
if line is None:
|
|
||||||
print("Warning: Can't detect number of CPU cores from cgroups",
|
|
||||||
file=sys.stderr)
|
|
||||||
return None
|
|
||||||
|
|
||||||
for group in line.split(','):
|
|
||||||
core_ids = list(map(int, group.split('-')))
|
|
||||||
if len(core_ids) == 2:
|
|
||||||
core_count += core_ids[1] - core_ids[0] + 1
|
|
||||||
else:
|
|
||||||
core_count += 1
|
|
||||||
|
|
||||||
return core_count
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
env_vars = {
|
|
||||||
"MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
|
|
||||||
"MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
|
|
||||||
"NUMBER_OF_CORES": get_number_of_cores()
|
|
||||||
}
|
|
||||||
|
|
||||||
env_vars = {k: v for k, v in env_vars.items() if v is not None}
|
|
||||||
|
|
||||||
if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
|
|
||||||
env_vars["NO_MEMORY_LIMIT"] = "true"
|
|
||||||
|
|
||||||
for key, value in env_vars.items():
|
|
||||||
print("{0}={1}".format(key, value))
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Fix permissions on the given directory to allow group read/write of
|
|
||||||
# regular files and execute of directories.
|
|
||||||
find $1 -exec chgrp 0 {} \;
|
|
||||||
find $1 -exec chmod g+rw {} \;
|
|
||||||
find $1 -type d -exec chmod g+x {} +
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
DocumentRoot "/opt/app-root/src${DOCUMENTROOT}"
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
<IfModule mpm_prefork_module>
|
|
||||||
# This value should mirror what is set in MinSpareServers.
|
|
||||||
StartServers ${HTTPD_START_SERVERS}
|
|
||||||
MinSpareServers ${HTTPD_START_SERVERS}
|
|
||||||
MaxSpareServers ${HTTPD_MAX_SPARE_SERVERS}
|
|
||||||
# The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served.
|
|
||||||
# The default value, when no Cgroup limits are set is 256.
|
|
||||||
MaxRequestWorkers ${HTTPD_MAX_REQUEST_WORKERS}
|
|
||||||
ServerLimit ${HTTPD_MAX_REQUEST_WORKERS}
|
|
||||||
MaxRequestsPerChild 4000
|
|
||||||
MaxKeepAliveRequests 100
|
|
||||||
</IfModule>
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
s/^Listen 80/Listen 0.0.0.0:8080/
|
|
||||||
s/^User apache/User default/
|
|
||||||
s/^Group apache/Group root/
|
|
||||||
s%^DocumentRoot "/var/www/html"%#DocumentRoot "/opt/app-root/src"%
|
|
||||||
s%^<Directory "/var/www/html"%<Directory "/opt/app-root/src"%
|
|
||||||
s%^<Directory "/var/html"%<Directory "/opt/app-root/src"%
|
|
||||||
s%^ErrorLog "logs/error_log"%ErrorLog "|/usr/bin/cat"%
|
|
||||||
s%CustomLog "logs/access_log"%CustomLog "|/usr/bin/cat"%
|
|
||||||
151s%AllowOverride None%AllowOverride All%
|
|
||||||
|
|
@ -1,113 +0,0 @@
|
||||||
; Enable Zend OPcache extension module
|
|
||||||
zend_extension=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=${OPCACHE_REVALIDATE_FREQ}
|
|
||||||
|
|
||||||
; 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 enabled, a fast shutdown sequence is used for the accelerated code
|
|
||||||
;opcache.fast_shutdown=0
|
|
||||||
|
|
||||||
; 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=/etc/opt/rh/rh-php70/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
|
|
||||||
|
|
||||||
; Allows calling OPcache API functions only from PHP scripts which path is
|
|
||||||
; started from specified string. The default "" means no restriction
|
|
||||||
;opcache.restrict_api=
|
|
||||||
|
|
||||||
; Enables and sets the second level cache directory.
|
|
||||||
; It should improve performance when SHM memory is full, at server restart or
|
|
||||||
; SHM reset. The default "" disables file based caching.
|
|
||||||
; RPM note : file cache directory must be owned by process owner
|
|
||||||
; for mod_php, see /etc/httpd/conf.d/php.conf
|
|
||||||
; for php-fpm, see /etc/php-fpm.d/*conf
|
|
||||||
;opcache.file_cache=
|
|
||||||
|
|
||||||
; Enables or disables opcode caching in shared memory.
|
|
||||||
;opcache.file_cache_only=0
|
|
||||||
|
|
||||||
; Enables or disables checksum validation when script loaded from file cache.
|
|
||||||
;opcache.file_cache_consistency_checks=1
|
|
||||||
|
|
||||||
|
|
||||||
; Enables or disables copying of PHP code (text segment) into HUGE PAGES.
|
|
||||||
; This should improve performance, but requires appropriate OS configuration.
|
|
||||||
;opcache.huge_code_pages=0
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load diff
1
dead.package
Normal file
1
dead.package
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Container not being built in Fedora infrastructure for years, check gitlab.com/sclorg instead
|
||||||
|
|
@ -1,141 +0,0 @@
|
||||||
---
|
|
||||||
kind: Template
|
|
||||||
apiVersion: v1
|
|
||||||
metadata:
|
|
||||||
name: php-fedora
|
|
||||||
annotations:
|
|
||||||
description: Php source to image builder
|
|
||||||
tags: php s2i
|
|
||||||
iconClass: icon-php
|
|
||||||
labels:
|
|
||||||
template: php
|
|
||||||
role: php_application_builder
|
|
||||||
objects:
|
|
||||||
- kind : ImageStream
|
|
||||||
apiVersion : v1
|
|
||||||
metadata :
|
|
||||||
name : ${APP_NAME}
|
|
||||||
labels :
|
|
||||||
appid : php-${APP_NAME}
|
|
||||||
- kind : ImageStream
|
|
||||||
apiVersion : v1
|
|
||||||
metadata :
|
|
||||||
name : ${APP_NAME}-s2i
|
|
||||||
labels :
|
|
||||||
appid : php-${APP_NAME}
|
|
||||||
spec :
|
|
||||||
tags :
|
|
||||||
- name : latest
|
|
||||||
from :
|
|
||||||
kind : DockerImage
|
|
||||||
name : modularitycontainers/php
|
|
||||||
- kind : BuildConfig
|
|
||||||
apiVersion : v1
|
|
||||||
metadata :
|
|
||||||
name : ${APP_NAME}
|
|
||||||
labels :
|
|
||||||
appid : php-${APP_NAME}
|
|
||||||
spec :
|
|
||||||
triggers :
|
|
||||||
- type : ConfigChange
|
|
||||||
- type : ImageChange
|
|
||||||
- type : GitHub
|
|
||||||
github:
|
|
||||||
secret: secret101
|
|
||||||
source :
|
|
||||||
type : Git
|
|
||||||
git :
|
|
||||||
uri : ${SOURCE_REPOSITORY}
|
|
||||||
contextDir : ${SOURCE_REPOSITORY}
|
|
||||||
strategy :
|
|
||||||
type : Source
|
|
||||||
sourceStrategy :
|
|
||||||
from :
|
|
||||||
kind : ImageStreamTag
|
|
||||||
name : ${APP_NAME}-s2i:latest
|
|
||||||
output :
|
|
||||||
to :
|
|
||||||
kind : ImageStreamTag
|
|
||||||
name : ${APP_NAME}:latest
|
|
||||||
- kind : DeploymentConfig
|
|
||||||
apiVersion : v1
|
|
||||||
metadata :
|
|
||||||
name: ${APP_NAME}
|
|
||||||
labels :
|
|
||||||
appid : php-${APP_NAME}
|
|
||||||
spec :
|
|
||||||
strategy :
|
|
||||||
type : Rolling
|
|
||||||
triggers :
|
|
||||||
- type : ConfigChange
|
|
||||||
- type : ImageChange
|
|
||||||
imageChangeParams :
|
|
||||||
automatic : true
|
|
||||||
containerNames :
|
|
||||||
- ${APP_NAME}
|
|
||||||
from :
|
|
||||||
kind : ImageStreamTag
|
|
||||||
name : ${APP_NAME}:latest
|
|
||||||
replicas : 1
|
|
||||||
selector :
|
|
||||||
deploymentconfig : ${APP_NAME}
|
|
||||||
template :
|
|
||||||
metadata :
|
|
||||||
labels :
|
|
||||||
appid: php-${APP_NAME}
|
|
||||||
deploymentconfig : ${APP_NAME}
|
|
||||||
spec :
|
|
||||||
containers :
|
|
||||||
- name : ${APP_NAME}
|
|
||||||
image : ${APP_NAME}:latest
|
|
||||||
ports :
|
|
||||||
- containerPort : 8080
|
|
||||||
protocol : TCP
|
|
||||||
livenessProbe:
|
|
||||||
tcpSocket:
|
|
||||||
port: 8080
|
|
||||||
initialDelaySeconds: 15
|
|
||||||
timeoutSeconds: 1
|
|
||||||
readinessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /
|
|
||||||
port: 8080
|
|
||||||
initialDelaySeconds: 15
|
|
||||||
timeoutSeconds: 1
|
|
||||||
- kind : Service
|
|
||||||
apiVersion : v1
|
|
||||||
metadata :
|
|
||||||
name : ${APP_NAME}
|
|
||||||
labels :
|
|
||||||
appid : php-${APP_NAME}
|
|
||||||
spec :
|
|
||||||
ports :
|
|
||||||
- name: 8080-tcp
|
|
||||||
protocol : TCP
|
|
||||||
port : 8080
|
|
||||||
targetPort : 8080
|
|
||||||
selector :
|
|
||||||
deploymentconfig : ${APP_NAME}
|
|
||||||
- kind : Route
|
|
||||||
apiVersion : v1
|
|
||||||
metadata :
|
|
||||||
name : ${APP_NAME}
|
|
||||||
labels :
|
|
||||||
appid : php-${APP_NAME}
|
|
||||||
spec :
|
|
||||||
host :
|
|
||||||
to :
|
|
||||||
kind : Service
|
|
||||||
name : ${APP_NAME}
|
|
||||||
weight : 100
|
|
||||||
port :
|
|
||||||
targetPort : 8080-tcp
|
|
||||||
parameters :
|
|
||||||
- name : APP_NAME
|
|
||||||
description : Name of application
|
|
||||||
value :
|
|
||||||
required : true
|
|
||||||
- name : SOURCE_REPOSITORY
|
|
||||||
description : Git source repository
|
|
||||||
value :
|
|
||||||
required : true
|
|
||||||
191
root/help.1
191
root/help.1
|
|
@ -1,191 +0,0 @@
|
||||||
.TH "php" "1" "" "Rado Pitonak \<rpitonak@redhat.com\>" "DATE 07.04.2017" ""
|
|
||||||
|
|
||||||
|
|
||||||
.SH NAME
|
|
||||||
.PP
|
|
||||||
php \- source to image builder of php applications.
|
|
||||||
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.PP
|
|
||||||
Image for building php application as reproducible Docker image using source to image. Image is based on fedora.
|
|
||||||
|
|
||||||
.SH USAGE
|
|
||||||
.PP
|
|
||||||
To pull the php container run:
|
|
||||||
|
|
||||||
.PP
|
|
||||||
.RS
|
|
||||||
|
|
||||||
.nf
|
|
||||||
# docker pull modularitycontainers/php
|
|
||||||
|
|
||||||
.fi
|
|
||||||
.RE
|
|
||||||
|
|
||||||
.PP
|
|
||||||
To build your php application run:
|
|
||||||
|
|
||||||
.PP
|
|
||||||
.RS
|
|
||||||
|
|
||||||
.nf
|
|
||||||
# s2i build <SOURCE\-REPOSITORY> modularitycontainers/php <NAME\-OF\-APP>
|
|
||||||
|
|
||||||
.fi
|
|
||||||
.RE
|
|
||||||
|
|
||||||
.PP
|
|
||||||
To run your application in docker container:
|
|
||||||
|
|
||||||
.PP
|
|
||||||
.RS
|
|
||||||
|
|
||||||
.nf
|
|
||||||
# docker run \-p 8080:8080 <NAME\-OF\-APP>
|
|
||||||
|
|
||||||
.fi
|
|
||||||
.RE
|
|
||||||
|
|
||||||
.SH ENVIROMENT VARIABLES
|
|
||||||
.PP
|
|
||||||
To set environment variables, you can place them as a key value pair into a \fB\fC.sti/environment\fR
|
|
||||||
file inside your source code repository.
|
|
||||||
|
|
||||||
.PP
|
|
||||||
The following environment variables set their equivalent property value in the php.ini file:
|
|
||||||
|
|
||||||
.PP
|
|
||||||
ERROR\_REPORTING
|
|
||||||
Informs PHP of which errors, warnings and notices you would like it to take action for.
|
|
||||||
Default: E\_ALL \& \~E\_NOTICE
|
|
||||||
|
|
||||||
.PP
|
|
||||||
DISPLAY\_ERRORS
|
|
||||||
Controls whether or not and where PHP will output errors, notices and warnings.
|
|
||||||
Default: ON
|
|
||||||
|
|
||||||
.PP
|
|
||||||
DISPLAY\_STARTUP\_ERRORS
|
|
||||||
Cause display errors which occur during PHP's startup sequence to be handled separately from display errors.
|
|
||||||
Default: OFF
|
|
||||||
|
|
||||||
.PP
|
|
||||||
TRACK\_ERRORS
|
|
||||||
Store the last error/warning message in $php\_errormsg (boolean)
|
|
||||||
Default: OFF
|
|
||||||
|
|
||||||
.PP
|
|
||||||
HTML\_ERRORS
|
|
||||||
Link errors to documentation related to the error
|
|
||||||
Default: ON
|
|
||||||
|
|
||||||
.PP
|
|
||||||
INCLUDE\_PATH
|
|
||||||
Path for PHP source files
|
|
||||||
Default: .:/opt/app\-root/src:/usr/share/pear
|
|
||||||
|
|
||||||
.PP
|
|
||||||
SESSION\_PATH
|
|
||||||
Location for session data files
|
|
||||||
Default: /tmp/sessions
|
|
||||||
|
|
||||||
.PP
|
|
||||||
SHORT\_OPEN\_TAG
|
|
||||||
Determines whether or not PHP will recognize code between <? and ?> tags
|
|
||||||
Default: OFF
|
|
||||||
|
|
||||||
.PP
|
|
||||||
DOCUMENTROOT
|
|
||||||
Path that defines the DocumentRoot for your application (ie. /public)
|
|
||||||
Default: /
|
|
||||||
|
|
||||||
.PP
|
|
||||||
The following environment variables set their equivalent property value in the opcache.ini file:
|
|
||||||
|
|
||||||
.PP
|
|
||||||
OPCACHE\_MEMORY\_CONSUMPTION
|
|
||||||
The OPcache shared memory storage size in megabytes
|
|
||||||
Default: 128
|
|
||||||
|
|
||||||
.PP
|
|
||||||
OPCACHE\_REVALIDATE\_FREQ
|
|
||||||
How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.
|
|
||||||
Default: 2
|
|
||||||
|
|
||||||
.PP
|
|
||||||
You can also override the entire directory used to load the PHP configuration by setting:
|
|
||||||
|
|
||||||
.PP
|
|
||||||
PHPRC
|
|
||||||
Sets the path to the php.ini file
|
|
||||||
|
|
||||||
.PP
|
|
||||||
PHP\_INI\_SCAN\_DIR
|
|
||||||
Path to scan for additional ini configuration files
|
|
||||||
|
|
||||||
.PP
|
|
||||||
You can override the Apache MPM prefork settings to increase the performance for of the PHP application. In case you set
|
|
||||||
the Cgroup limits in Docker, the image will attempt to automatically set the
|
|
||||||
optimal values. You can override this at any time by specifying the values
|
|
||||||
yourself:
|
|
||||||
|
|
||||||
.PP
|
|
||||||
HTTPD\_START\_SERVERS
|
|
||||||
The StartServers directive sets the number of child server processes created on startup.
|
|
||||||
Default: 8
|
|
||||||
|
|
||||||
.PP
|
|
||||||
HTTPD\_MAX\_REQUEST\_WORKERS
|
|
||||||
The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served.
|
|
||||||
\fB\fCMaxRequestWorkers\fR was called \fB\fCMaxClients\fR before version httpd 2.3.13.
|
|
||||||
Default: 256 (this is automatically tuned by setting Cgroup limits for the container using this formula:
|
|
||||||
\fB\fCTOTAL\_MEMORY / 15MB\fR. The 15MB is average size of a single httpd process.
|
|
||||||
|
|
||||||
.PP
|
|
||||||
You can use a custom composer repository mirror URL to download packages instead of the default 'packagist.org':
|
|
||||||
|
|
||||||
.PP
|
|
||||||
COMPOSER\_MIRROR
|
|
||||||
Adds a custom composer repository mirror URL to composer configuration. Note: This only affects packages listed in composer.json.
|
|
||||||
|
|
||||||
.SH HOT DEPLOY
|
|
||||||
.PP
|
|
||||||
In order to immediately pick up changes made in your application source code, you need to run your built image with the \fB\fCOPCACHE\_REVALIDATE\_FREQ=0\fR environment variable passed to the Docker \fB\fC\-e\fR run flag:
|
|
||||||
|
|
||||||
.PP
|
|
||||||
.RS
|
|
||||||
|
|
||||||
.nf
|
|
||||||
# docker run \-e OPCACHE\_REVALIDATE\_FREQ=0 \-p 8080:8080 php\-app
|
|
||||||
|
|
||||||
.fi
|
|
||||||
.RE
|
|
||||||
|
|
||||||
.PP
|
|
||||||
To change your source code in running container, use Docker's exec command:
|
|
||||||
|
|
||||||
.PP
|
|
||||||
.RS
|
|
||||||
|
|
||||||
.nf
|
|
||||||
# docker exec \-it <CONTAINER\_ID> /bin/bash
|
|
||||||
|
|
||||||
.fi
|
|
||||||
.RE
|
|
||||||
|
|
||||||
.PP
|
|
||||||
After you Docker exec into the running container, your current directory is set to \fB\fC/opt/app\-root/src\fR, where the source code is located.
|
|
||||||
|
|
||||||
.SH SECURITY IMPLICATIONS
|
|
||||||
.PP
|
|
||||||
\-p 8080:8080
|
|
||||||
|
|
||||||
.PP
|
|
||||||
.RS
|
|
||||||
|
|
||||||
.nf
|
|
||||||
Opens container port 8080 and maps it to the same port on the Host.
|
|
||||||
|
|
||||||
.fi
|
|
||||||
.RE
|
|
||||||
121
root/help.md
121
root/help.md
|
|
@ -1,121 +0,0 @@
|
||||||
% php(1)
|
|
||||||
% Rado Pitonak \<rpitonak@redhat.com\>
|
|
||||||
% DATE 07.04.2017
|
|
||||||
|
|
||||||
# NAME
|
|
||||||
php - source to image builder of php applications.
|
|
||||||
|
|
||||||
# DESCRIPTION
|
|
||||||
Image for building php application as reproducible Docker image using source to image. Image is based on fedora.
|
|
||||||
## USAGE
|
|
||||||
|
|
||||||
To pull the php container run:
|
|
||||||
|
|
||||||
# docker pull modularitycontainers/php
|
|
||||||
|
|
||||||
To build your php application run:
|
|
||||||
|
|
||||||
# s2i build <SOURCE-REPOSITORY> modularitycontainers/php <NAME-OF-APP>
|
|
||||||
|
|
||||||
To run your application in docker container:
|
|
||||||
|
|
||||||
# docker run -p 8080:8080 <NAME-OF-APP>
|
|
||||||
|
|
||||||
## ENVIROMENT VARIABLES
|
|
||||||
|
|
||||||
To set environment variables, you can place them as a key value pair into a `.sti/environment`
|
|
||||||
file inside your source code repository.
|
|
||||||
|
|
||||||
The following environment variables set their equivalent property value in the php.ini file:
|
|
||||||
|
|
||||||
ERROR_REPORTING
|
|
||||||
Informs PHP of which errors, warnings and notices you would like it to take action for.
|
|
||||||
Default: E_ALL & ~E_NOTICE
|
|
||||||
|
|
||||||
DISPLAY_ERRORS
|
|
||||||
Controls whether or not and where PHP will output errors, notices and warnings.
|
|
||||||
Default: ON
|
|
||||||
|
|
||||||
DISPLAY_STARTUP_ERRORS
|
|
||||||
Cause display errors which occur during PHP's startup sequence to be handled separately from display errors.
|
|
||||||
Default: OFF
|
|
||||||
|
|
||||||
TRACK_ERRORS
|
|
||||||
Store the last error/warning message in $php_errormsg (boolean)
|
|
||||||
Default: OFF
|
|
||||||
|
|
||||||
HTML_ERRORS
|
|
||||||
Link errors to documentation related to the error
|
|
||||||
Default: ON
|
|
||||||
|
|
||||||
INCLUDE_PATH
|
|
||||||
Path for PHP source files
|
|
||||||
Default: .:/opt/app-root/src:/usr/share/pear
|
|
||||||
|
|
||||||
SESSION_PATH
|
|
||||||
Location for session data files
|
|
||||||
Default: /tmp/sessions
|
|
||||||
|
|
||||||
SHORT_OPEN_TAG
|
|
||||||
Determines whether or not PHP will recognize code between <? and ?> tags
|
|
||||||
Default: OFF
|
|
||||||
|
|
||||||
DOCUMENTROOT
|
|
||||||
Path that defines the DocumentRoot for your application (ie. /public)
|
|
||||||
Default: /
|
|
||||||
|
|
||||||
The following environment variables set their equivalent property value in the opcache.ini file:
|
|
||||||
|
|
||||||
OPCACHE_MEMORY_CONSUMPTION
|
|
||||||
The OPcache shared memory storage size in megabytes
|
|
||||||
Default: 128
|
|
||||||
|
|
||||||
OPCACHE_REVALIDATE_FREQ
|
|
||||||
How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.
|
|
||||||
Default: 2
|
|
||||||
|
|
||||||
You can also override the entire directory used to load the PHP configuration by setting:
|
|
||||||
|
|
||||||
PHPRC
|
|
||||||
Sets the path to the php.ini file
|
|
||||||
|
|
||||||
PHP_INI_SCAN_DIR
|
|
||||||
Path to scan for additional ini configuration files
|
|
||||||
|
|
||||||
You can override the Apache MPM prefork settings to increase the performance for of the PHP application. In case you set
|
|
||||||
the Cgroup limits in Docker, the image will attempt to automatically set the
|
|
||||||
optimal values. You can override this at any time by specifying the values
|
|
||||||
yourself:
|
|
||||||
|
|
||||||
HTTPD_START_SERVERS
|
|
||||||
The StartServers directive sets the number of child server processes created on startup.
|
|
||||||
Default: 8
|
|
||||||
|
|
||||||
HTTPD_MAX_REQUEST_WORKERS
|
|
||||||
The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served.
|
|
||||||
`MaxRequestWorkers` was called `MaxClients` before version httpd 2.3.13.
|
|
||||||
Default: 256 (this is automatically tuned by setting Cgroup limits for the container using this formula:
|
|
||||||
`TOTAL_MEMORY / 15MB`. The 15MB is average size of a single httpd process.
|
|
||||||
|
|
||||||
You can use a custom composer repository mirror URL to download packages instead of the default 'packagist.org':
|
|
||||||
|
|
||||||
COMPOSER_MIRROR
|
|
||||||
Adds a custom composer repository mirror URL to composer configuration. Note: This only affects packages listed in composer.json.
|
|
||||||
|
|
||||||
## HOT DEPLOY
|
|
||||||
|
|
||||||
In order to immediately pick up changes made in your application source code, you need to run your built image with the `OPCACHE_REVALIDATE_FREQ=0` environment variable passed to the Docker `-e` run flag:
|
|
||||||
|
|
||||||
# docker run -e OPCACHE_REVALIDATE_FREQ=0 -p 8080:8080 php-app
|
|
||||||
|
|
||||||
To change your source code in running container, use Docker's exec command:
|
|
||||||
|
|
||||||
# docker exec -it <CONTAINER_ID> /bin/bash
|
|
||||||
|
|
||||||
After you Docker exec into the running container, your current directory is set to `/opt/app-root/src`, where the source code is located.
|
|
||||||
|
|
||||||
## SECURITY IMPLICATIONS
|
|
||||||
|
|
||||||
-p 8080:8080
|
|
||||||
|
|
||||||
Opens container port 8080 and maps it to the same port on the Host.
|
|
||||||
1
test/.gitignore
vendored
1
test/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
.git/
|
|
||||||
193
test/run
193
test/run
|
|
@ -1,193 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# The 'run' performs a simple test that verifies the S2I image.
|
|
||||||
# The main focus here is to exercise the S2I scripts.
|
|
||||||
#
|
|
||||||
# For more information see the documentation:
|
|
||||||
# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
|
|
||||||
#
|
|
||||||
# IMAGE_NAME specifies a name of the candidate image used for testing.
|
|
||||||
# The image has to be available before this script is executed.
|
|
||||||
#
|
|
||||||
IMAGE_NAME=${IMAGE_NAME-php-candidate}
|
|
||||||
|
|
||||||
# Determining system utility executables (darwin compatibility check)
|
|
||||||
READLINK_EXEC="readlink"
|
|
||||||
MKTEMP_EXEC="mktemp"
|
|
||||||
if [[ "$OSTYPE" =~ 'darwin' ]]; then
|
|
||||||
! type -a "greadlink" &>"/dev/null" || READLINK_EXEC="greadlink"
|
|
||||||
! type -a "gmktemp" &>"/dev/null" || MKTEMP_EXEC="gmktemp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
test_dir="$($READLINK_EXEC -zf $(dirname "${BASH_SOURCE[0]}"))"
|
|
||||||
image_dir=$($READLINK_EXEC -zf ${test_dir}/..)
|
|
||||||
scripts_url="file://${image_dir}/.s2i/bin"
|
|
||||||
cid_file=$($MKTEMP_EXEC -u --suffix=.cid)
|
|
||||||
|
|
||||||
# Since we built the candidate image locally, we don't want S2I to attempt to pull
|
|
||||||
# it from Docker hub
|
|
||||||
s2i_args="--force-pull=false"
|
|
||||||
|
|
||||||
# Port the image exposes service to be tested
|
|
||||||
test_port=8080
|
|
||||||
|
|
||||||
info() {
|
|
||||||
echo -e "\n\e[1m[INFO] $@...\e[0m\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
image_exists() {
|
|
||||||
docker inspect $1 &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
container_exists() {
|
|
||||||
image_exists $(cat $cid_file)
|
|
||||||
}
|
|
||||||
|
|
||||||
container_ip() {
|
|
||||||
if [ ! -z "$DOCKER_HOST" ] && [[ "$OSTYPE" =~ 'darwin' ]]; then
|
|
||||||
docker-machine ip
|
|
||||||
else
|
|
||||||
docker inspect --format="{{ .NetworkSettings.IPAddress }}" $(cat $cid_file)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
container_port() {
|
|
||||||
if [ ! -z "$DOCKER_HOST" ] && [[ "$OSTYPE" =~ 'darwin' ]]; then
|
|
||||||
docker inspect --format="{{(index .NetworkSettings.Ports \"$test_port/tcp\" 0).HostPort}}" "$(cat "${cid_file}")"
|
|
||||||
else
|
|
||||||
echo $test_port
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
run_s2i_build() {
|
|
||||||
s2i build --incremental=true ${s2i_args} file://${test_dir}/test-app ${IMAGE_NAME} ${IMAGE_NAME}-testapp
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare() {
|
|
||||||
if ! image_exists ${IMAGE_NAME}; then
|
|
||||||
echo "ERROR: The image ${IMAGE_NAME} must exist before this script is executed."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# s2i build requires the application is a valid 'Git' repository
|
|
||||||
pushd ${test_dir}/test-app >/dev/null
|
|
||||||
git init
|
|
||||||
git config user.email "build@localhost" && git config user.name "builder"
|
|
||||||
git add -A && git commit -m "Sample commit"
|
|
||||||
popd >/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
run_test_application() {
|
|
||||||
docker run --user=100001 --rm --cidfile=${cid_file} -p ${test_port} ${IMAGE_NAME}-testapp
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup_test_app() {
|
|
||||||
info "Cleaning up the test application"
|
|
||||||
if [ -f $cid_file ]; then
|
|
||||||
if container_exists; then
|
|
||||||
docker stop $(cat $cid_file)
|
|
||||||
docker rm $(cat $cid_file)
|
|
||||||
fi
|
|
||||||
rm $cid_file
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup() {
|
|
||||||
if [ -f $cid_file ]; then
|
|
||||||
if container_exists; then
|
|
||||||
docker stop $(cat $cid_file)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if image_exists ${IMAGE_NAME}-testapp; then
|
|
||||||
docker rmi -f ${IMAGE_NAME}-testapp
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_result() {
|
|
||||||
local result="$1"
|
|
||||||
if [[ "$result" != "0" ]]; then
|
|
||||||
echo "S2I image '${IMAGE_NAME}' test FAILED (exit code: ${result})"
|
|
||||||
cleanup
|
|
||||||
exit $result
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_for_cid() {
|
|
||||||
local max_attempts=10
|
|
||||||
local sleep_time=1
|
|
||||||
local attempt=1
|
|
||||||
local result=1
|
|
||||||
while [ $attempt -le $max_attempts ]; do
|
|
||||||
[ -f $cid_file ] && break
|
|
||||||
echo "Waiting for container to start..."
|
|
||||||
attempt=$(( $attempt + 1 ))
|
|
||||||
sleep $sleep_time
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
test_s2i_usage() {
|
|
||||||
echo "Testing 's2i usage'..."
|
|
||||||
s2i usage ${s2i_args} ${IMAGE_NAME} &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
test_docker_run_usage() {
|
|
||||||
info "Testing 'docker run' usage"
|
|
||||||
docker run ${IMAGE_NAME} &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
test_connection() {
|
|
||||||
echo "Testing HTTP connection (http://$(container_ip):$(container_port))"
|
|
||||||
local max_attempts=10
|
|
||||||
local sleep_time=1
|
|
||||||
local attempt=1
|
|
||||||
local result=1
|
|
||||||
while [ $attempt -le $max_attempts ]; do
|
|
||||||
echo "Sending GET request to http://$(container_ip):$(container_port)/"
|
|
||||||
response_code=$(curl -s -w %{http_code} -o /dev/null http://$(container_ip):$(container_port)/)
|
|
||||||
status=$?
|
|
||||||
if [ $status -eq 0 ]; then
|
|
||||||
if [ $response_code -eq 200 ]; then
|
|
||||||
result=0
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
attempt=$(( $attempt + 1 ))
|
|
||||||
sleep $sleep_time
|
|
||||||
done
|
|
||||||
return $result
|
|
||||||
}
|
|
||||||
|
|
||||||
test_application() {
|
|
||||||
# Verify that the HTTP connection can be established to test application container
|
|
||||||
run_test_application &
|
|
||||||
|
|
||||||
# Wait for the container to write it's CID file
|
|
||||||
wait_for_cid
|
|
||||||
|
|
||||||
test_connection
|
|
||||||
check_result $?
|
|
||||||
cleanup_test_app
|
|
||||||
}
|
|
||||||
|
|
||||||
# Build the application image twice to ensure the 'save-artifacts' and
|
|
||||||
# 'restore-artifacts' scripts are working properly
|
|
||||||
prepare
|
|
||||||
run_s2i_build
|
|
||||||
check_result $?
|
|
||||||
|
|
||||||
# Verify the 'usage' script is working properly
|
|
||||||
test_s2i_usage
|
|
||||||
check_result $?
|
|
||||||
|
|
||||||
# Verify the 'usage' script is working properly when running the base image with 'docker run ...'
|
|
||||||
test_docker_run_usage
|
|
||||||
check_result $?
|
|
||||||
|
|
||||||
# Test application with default uid
|
|
||||||
test_application
|
|
||||||
|
|
||||||
# Test application with random uid
|
|
||||||
CONTAINER_ARGS="-u 12345" test_application
|
|
||||||
|
|
||||||
cleanup
|
|
||||||
|
|
||||||
info "All tests finished successfully."
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit df325a98b3498cbb0f18009f4640c4d6205934fe
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue