UNCLASSIFIED

Commit 596ee39e authored by Matt Vasquez's avatar Matt Vasquez
Browse files

Merge branch '7.4.8' into 'development'

PHP 7.4.8

See merge request !6
parents 2a4663ec cc4eeab3
ARG BASE_REGISTRY=nexus-docker-secure.levelup-nexus.svc.cluster.local:18082
ARG BASE_REGISTRY=registry1.dsop.io
ARG BASE_IMAGE=redhat/ubi/ubi8
ARG BASE_TAG=8.2
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} as builder
LABEL name="PHP" \
maintainer="seagren.tim@solute.us" \
vendor="Open Source" \
version="7.4.8" \
release="1" \
summary="Image containing PHP v7.4.8" \
description="PHP is a popular general-purpose scripting language that is especially suited to web development."
ENV PHP_INI_PATH=/usr/local/etc/php
LABEL org.opencontainers.image.title="php" \
org.opencontainers.image.description="PHP is a popular general-purpose scripting language that is especially suited to web development." \
org.opencontainers.image.licenses="PHP-3.01" \
org.opencontainers.image.url="https://www.php.net/" \
org.opencontainers.image.version="7.4.8" \
maintainer="cht@dsop.io"
COPY php.tar.gz /usr/local/src/
COPY bison.tar.gz /
......@@ -57,18 +58,68 @@ RUN dnf update --setopt=tsflags=nodocs -y \
&& rm /usr/local/src/php.tar.gz \
&& cd /usr/local/src/php \
&& ./buildconf --force \
&& ./configure --without-pear \
&& ./configure \
--with-fpm-user=1001 \
--with-fpm-group=1001 \
--with-config-file-path=${PHP_INI_PATH} \
--with-config-file-scan-dir=${PHP_INI_PATH}/conf.d \
--without-pear \
--with-pdo-sqlite=/usr \
--with-sqlite3=/usr \
--enable-fpm \
&& make -j4 \
&& make install \
&& for cert in $(find /usr/local/src/php/ext/ -name "*.pem" -o -name "*.phpt" -o -name "*.crt" -o -name "*.key"); do rm $cert; done
&& for cert in $(find /usr/local/src/php/ext/ -name "*.pem" -o -name "*.phpt" -o -name "*.crt" -o -name "*.key"); do rm $cert; done \
&& sed 's!=NONE/!=!g' /usr/local/etc/php-fpm.conf.default | tee /usr/local/etc/php-fpm.conf > /dev/null \
&& mv /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG}
COPY --from=builder /usr/local/bin/php /usr/local/bin/phar /usr/local/bin/php-cgi /usr/local/bin/php-config /usr/local/bin/phpdbg /usr/local/bin/phpize /usr/local/bin/
COPY --from=builder /usr/local/php /usr/local/php
COPY --from=builder /usr/local/include/php /usr/local/include/php
ENV PHP_INI_PATH=/usr/local/etc/php
RUN mkdir -p ${PHP_INI_PATH}/conf.d /usr/local/etc/php-fpm.d /usr/local/var/log/php-fpm \
&& chown -R 1001:1001 /usr/local/var/log/php-fpm/ \
&& { \
echo '[global]'; \
echo 'error_log = /proc/self/fd/2'; \
echo; echo '; https://github.com/docker-library/php/pull/725#issuecomment-443540114'; echo 'log_limit = 8192'; \
echo; \
echo '[www]'; \
echo '; if we send this to /proc/self/fd/1, it never appears'; \
echo 'access.log = /proc/self/fd/2'; \
echo; \
echo 'clear_env = no'; \
echo; \
echo '; Ensure worker stdout and stderr are sent to the main error log.'; \
echo 'catch_workers_output = yes'; \
echo 'decorate_workers_output = no'; \
} | tee /usr/local/etc/php-fpm.d/docker.conf \
&& { \
echo '[global]'; \
echo 'daemonize = no'; \
echo; \
echo '[www]'; \
echo 'listen = 9000'; \
} | tee /usr/local/etc/php-fpm.d/zz-docker.conf \
&& mkdir -p /var/www/html/ \
&& chown 1001:1001 /var/www/html \
&& chmod 777 /var/www/html \
&& chown -R 1001:1001 /usr/local/etc/
COPY --from=builder --chown=1001:1001 /usr/local/sbin/php-fpm /usr/local/bin/php /usr/local/bin/phar /usr/local/bin/php-cgi /usr/local/bin/php-config /usr/local/bin/phpdbg /usr/local/bin/phpize /usr/local/bin/
COPY --from=builder --chown=1001:1001 /usr/local/php /usr/local/php
COPY --from=builder --chown=1001:1001 /usr/local/etc/php-fpm.conf /usr/local/etc/
COPY --from=builder --chown=1001:1001 /usr/local/etc/php-fpm.d/ /usr/local/etc/php-fpm.d/
COPY --from=builder --chown=1001:1001 /usr/local/include/php /usr/local/include/php
COPY config/php.ini ${PHP_INI_PATH}/php.ini
COPY scripts/docker-php-entrypoint /usr/local/bin/entrypoint
USER 1001
ENTRYPOINT ["php"]
CMD ["-v"]
WORKDIR "/var/www/html"
ENTRYPOINT ["entrypoint"]
CMD ["php-fpm"]
HEALTHCHECK \
CMD curl -s http://localhost:9000; if [ $? = 56 ]; then exit 0; else exit 1; fi
Copyright (c) 2014 Docker, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 1999 - 2019 The PHP Group. All rights reserved.
--------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact group@php.net.
4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
5. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number.
Once covered code has been published under a particular version
of the license, you may always continue to use it under the terms
of that version. You may also choose to use such covered code
under the terms of any subsequent version of the license
published by the PHP Group. No one other than the PHP Group has
the right to modify the terms applicable to covered code created
under this License.
6. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes PHP software, freely available from
<http://www.php.net/software/>".
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------
This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.
The PHP Group can be contacted via Email at group@php.net.
For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.
PHP includes the Zend Engine, freely available at
<http://www.zend.com>.
# php
# PHP
PHP is a popular general-purpose scripting language that is especially suited to web development.
### Usage
This container contains the PHP 7.4.8 runtime and the PHP CLI, which is the default entrypoint. The default command is the `-v` flag, which will print version information for the PHP runtime installed.
This container hosts the PHP CLI and PHP-FPM, which is the default command fed to the entrypoint script, and will run continuously in the foreground on port 9000. PHP-FPM is the gateway program used by webservers to interpret PHP sourcecode.
*Build locally*: `docker build --build-arg BASE_REGISTRY=registry.access.redhat.com --build-arg BASE_IMAGE=ubi8/ubi -t php:7.4 .`
Alternatively, the PHP CLI may be called as the command to the entrypoint script.
*Run*: `docker run php:7.4`
The default configuration for PHP-FPM will look for PHP content in ``/var/www/html/``.
#### Kubernetes
While this container could be configured to run Apache httpd in addtion to PHP-FPM, it is preferable to run only a single service per container, especailly in a Kuberenetes context where multiple containers can easily work in conjunction with one another. Therefore, the recommended method of using this container is alongside another webserver container, such as nginx.
In order for for your webserver container and the php-fpm contianer to opperate successfully, you will need to crete a shared volume between the containers at /var/www/html/ (by default) containing the HTML and PHP content you wish to run.
**PHP manifest example**
```
apiVersion: apps/v1
kind: Deployment
metadata:
name: php-deployment
spec:
replicas: 1
template:
metadata:
name: php-pod
spec:
serviceAccount: php-sa
volumes:
- name: php
persistentVolumeClaim:
claimName: php-app-pvc
containers:
- image: nginx:1.17.6
name: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: "/var/www/html"
name: php-source
- image: php:7.4.8
name: php
ports:
- containerPort: 9000
volumeMounts:
- mountPath: "/var/www/html"
name: php-source
```
#### Configuration
#### PHP
The location searched for the php.ini file is specified by the ``${PHP_INI_PATH}`` environment variable, which is set to /usr/local/etc/php/ by default. To change default PHP behavior, you may do one of the following:
1. Replace the ``${PHP_INI_PATH}/pip.ini`` file with php.ini containing the desired settings
2. Add additional configuration in ``${PHP_INI_PATH}/conf.d``
3. Change the value of the ``${PHP_INI_PATH}`` env var to a directory containing your desired configuration files
See ``config/php.ini`` for the default settings for this image.
*Enabled Extensions*
The follwoing extensions are available by default in this image:
- fpm
- pdo-sqlite
- sqlite3
**NOTE**
fpm and PEAR are disabled by default for this image. To enable these, you will need to rerun the configuration script in `/usr/local/src/php` with the appropriate flags set/omitted.
PEAR is disabled by default for this image. To enable PEAR and other extensions, you will need to rerun the configuration script in `/usr/local/src/php` with the appropriate flags set/omitted.
#### PHP-FPM
PHP-FPM has its own configuration files, which are generated by the ./configure script run as part of this installation, and are located at ``/usr/local/etc/php-fpm.conf`` and ``/usr/local/etc/php-fpm.d/``.
This diff is collapsed.
#!/bin/sh
set -e
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- php-fpm "$@"
fi
exec "$@"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment