Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
8684050d1d | |||
fa910780a3 | |||
29d84fe54f | |||
2d544e1411 | |||
95f8846e3d | |||
30487a87e9 | |||
2d4afd080e | |||
35a35196e5 | |||
1db0abeb49 |
154
Dockerfile
154
Dockerfile
@ -1,45 +1,149 @@
|
|||||||
########################################################################################################################################
|
########################################################################################################################################
|
||||||
# Documentation: https://git.nickyeoman.com/4lt/phpcontainer/wiki
|
# Project: https://git.4lt.ca/4lt/phpcontainer/
|
||||||
########################################################################################################################################
|
# v4
|
||||||
FROM php:8.2.9-apache
|
#################################################################################################################################
|
||||||
|
|
||||||
|
# Use the PHP base image
|
||||||
|
# https://hub.docker.com/_/php
|
||||||
|
FROM php:8.3.9-apache
|
||||||
|
|
||||||
|
# Set maintainer information
|
||||||
|
LABEL version="4.0"
|
||||||
LABEL maintainer="4 Lights Consulting <info@4lt.ca>"
|
LABEL maintainer="4 Lights Consulting <info@4lt.ca>"
|
||||||
LABEL description="Production-ready PHP Apache container"
|
LABEL description="Production-ready PHP Apache container"
|
||||||
LABEL version="1"
|
LABEL org.label-schema.vcs-url="https://git.4lt.ca/4lt/phpcontainer"
|
||||||
LABEL org.label-schema.vcs-url="https://git.nickyeoman.com/4lt/phpcontainer"
|
|
||||||
|
|
||||||
# Setup
|
# Set working directory and Apache document root
|
||||||
WORKDIR /website
|
WORKDIR /data
|
||||||
ENV APACHE_DOCUMENT_ROOT /website/public/
|
ENV APACHE_DOCUMENT_ROOT /data/public/
|
||||||
|
|
||||||
# APT
|
# Install required packages
|
||||||
RUN apt-get update
|
RUN set -eux; \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends ghostscript;
|
||||||
|
|
||||||
# IMAP
|
# IMAP
|
||||||
RUN apt-get install -y libc-client-dev libkrb5-dev libssl-dev;
|
RUN apt-get install -y libc-client-dev libkrb5-dev libssl-dev;
|
||||||
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
|
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
|
||||||
RUN docker-php-ext-install imap
|
RUN docker-php-ext-install imap
|
||||||
|
|
||||||
# Symfony
|
# Install PHP extensions
|
||||||
RUN apt-get install -y libicu-dev
|
RUN set -ex; \
|
||||||
RUN docker-php-ext-configure intl
|
\
|
||||||
RUN docker-php-ext-install intl
|
savedAptMark="$(apt-mark showmanual)"; \
|
||||||
|
\
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
libbz2-dev \
|
||||||
|
libgmp-dev \
|
||||||
|
libicu-dev \
|
||||||
|
libfreetype6-dev \
|
||||||
|
libjpeg-dev \
|
||||||
|
libldap2-dev \
|
||||||
|
libmemcached-dev \
|
||||||
|
libmagickwand-dev \
|
||||||
|
libpq-dev \
|
||||||
|
libpng-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
libzip-dev \
|
||||||
|
; \
|
||||||
|
\
|
||||||
|
docker-php-ext-configure gd \
|
||||||
|
--with-freetype \
|
||||||
|
--with-jpeg \
|
||||||
|
--with-webp \
|
||||||
|
; \
|
||||||
|
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
|
||||||
|
docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \
|
||||||
|
docker-php-ext-configure intl; \
|
||||||
|
docker-php-ext-install -j "$(nproc)" \
|
||||||
|
bz2 \
|
||||||
|
bcmath \
|
||||||
|
exif \
|
||||||
|
gd \
|
||||||
|
gmp \
|
||||||
|
intl \
|
||||||
|
ldap \
|
||||||
|
mysqli \
|
||||||
|
pdo_mysql \
|
||||||
|
pdo_pgsql \
|
||||||
|
pgsql \
|
||||||
|
zip \
|
||||||
|
; \
|
||||||
|
pecl install imagick-3.6.0 && \
|
||||||
|
docker-php-ext-enable imagick && \
|
||||||
|
rm -r /tmp/pear; \
|
||||||
|
\
|
||||||
|
out="$(php -r 'exit(0);')"; \
|
||||||
|
[ -z "$out" ]; \
|
||||||
|
err="$(php -r 'exit(0);' 3>&1 1>&2 2>&3)"; \
|
||||||
|
[ -z "$err" ]; \
|
||||||
|
\
|
||||||
|
extDir="$(php -r 'echo ini_get("extension_dir");')"; \
|
||||||
|
[ -d "$extDir" ]; \
|
||||||
|
\
|
||||||
|
pecl install APCu-5.1.21 && \
|
||||||
|
pecl install memcached-3.2.0 && \
|
||||||
|
pecl install redis-5.3.7 && \
|
||||||
|
\
|
||||||
|
docker-php-ext-enable \
|
||||||
|
apcu \
|
||||||
|
memcached \
|
||||||
|
redis && \
|
||||||
|
rm -r /tmp/pear; \
|
||||||
|
\
|
||||||
|
apt-mark auto '.*' > /dev/null && \
|
||||||
|
apt-mark manual $savedAptMark && \
|
||||||
|
ldd "$extDir"/*.so | awk '/=>/ { print $3 }' | sort -u | xargs -r dpkg-query -S | cut -d: -f1 | sort -u | xargs -rt apt-mark manual; \
|
||||||
|
\
|
||||||
|
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
|
||||||
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
|
! { ldd "$extDir"/*.so | grep 'not found'; } && \
|
||||||
|
err="$(php --version 3>&1 1>&2 2>&3)"; \
|
||||||
|
[ -z "$err" ]
|
||||||
|
|
||||||
# Cleanup
|
# Set recommended PHP.ini settings
|
||||||
RUN rm -r /var/lib/apt/lists/*
|
RUN set -eux; \
|
||||||
|
docker-php-ext-enable opcache; \
|
||||||
|
{ \
|
||||||
|
echo 'opcache.memory_consumption=128'; \
|
||||||
|
echo 'opcache.interned_strings_buffer=8'; \
|
||||||
|
echo 'opcache.max_accelerated_files=4000'; \
|
||||||
|
echo 'opcache.revalidate_freq=2'; \
|
||||||
|
echo 'opcache.fast_shutdown=1'; \
|
||||||
|
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
|
||||||
|
|
||||||
# Apache settings
|
# Set recommended error logging
|
||||||
|
RUN { \
|
||||||
|
echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR'; \
|
||||||
|
echo 'display_errors = Off'; \
|
||||||
|
echo 'display_startup_errors = Off'; \
|
||||||
|
echo 'log_errors = On'; \
|
||||||
|
echo 'error_log = /dev/stderr'; \
|
||||||
|
echo 'log_errors_max_len = 1024'; \
|
||||||
|
echo 'ignore_repeated_errors = On'; \
|
||||||
|
echo 'ignore_repeated_source = Off'; \
|
||||||
|
echo 'html_errors = Off'; \
|
||||||
|
} > /usr/local/etc/php/conf.d/error-logging.ini
|
||||||
|
|
||||||
|
# Enable Apache modules and configure RemoteIP
|
||||||
|
RUN set -eux; \
|
||||||
|
a2enmod expires headers rewrite remoteip socache_shmcb ssl && \
|
||||||
|
{ \
|
||||||
|
echo 'RemoteIPHeader X-Forwarded-For'; \
|
||||||
|
echo 'RemoteIPTrustedProxy 10.0.0.0/8'; \
|
||||||
|
echo 'RemoteIPTrustedProxy 172.16.0.0/12'; \
|
||||||
|
echo 'RemoteIPTrustedProxy 192.168.0.0/16'; \
|
||||||
|
echo 'RemoteIPTrustedProxy 169.254.0.0/16'; \
|
||||||
|
echo 'RemoteIPTrustedProxy 127.0.0.0/8'; \
|
||||||
|
} > /etc/apache2/conf-available/remoteip.conf; \
|
||||||
|
a2enconf remoteip; \
|
||||||
|
find /etc/apache2 -type f -name '*.conf' -exec sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +
|
||||||
|
|
||||||
|
# More Apache settings
|
||||||
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
|
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
|
||||||
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
||||||
|
|
||||||
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
|
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
|
||||||
|
|
||||||
RUN a2enmod expires headers rewrite socache_shmcb ssl
|
|
||||||
|
|
||||||
RUN docker-php-ext-install mysqli pdo pdo_mysql
|
|
||||||
RUN docker-php-ext-install opcache
|
|
||||||
|
|
||||||
# Docker config
|
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD ["apache2-foreground"]
|
CMD ["apache2-foreground"]
|
||||||
|
39
README.md
39
README.md
@ -1,16 +1,35 @@
|
|||||||
# 4 Lights Consulting
|
# 4 Lights Consulting
|
||||||
|
|
||||||
The apache php docker container that we use for production.
|
The apache php docker container that 4 Lights uses for production.
|
||||||
|
|
||||||
User Documentation: https://git.nickyeoman.com/4lt/phpcontainer/wiki
|
Dockerhub: https://hub.docker.com/r/4lights/phpcontainer
|
||||||
|
|
||||||
## Development Documentation
|
## How to update
|
||||||
|
|
||||||
You might have to login with your api key.
|
Clone the project: ```git clone git@git.4lt.ca:4lt/phpcontainer.git```
|
||||||
```
|
|
||||||
sudo docker build -t phpcontainer:1 .
|
Update the Dockerfile.
|
||||||
sudo docker tag phpcontainer:1 4lights/phpcontainer:v1
|
|
||||||
sudo docker tag phpcontainer:1 4lights/phpcontainer:latest
|
Build (be sure to change the version number)
|
||||||
sudo docker push 4lights/phpcontainer:v1
|
|
||||||
sudo docker push 4lights/phpcontainer:latest
|
```bash
|
||||||
|
podman buildx build --no-cache -t 4lights/phpcontainer:v5 -t 4lights/phpcontainer:latest --load .
|
||||||
|
podman login
|
||||||
|
podman push 4lights/phpcontainer:v4
|
||||||
|
podman push 4lights/phpcontainer:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# References And Notes
|
||||||
|
|
||||||
|
* [Stack Overflow IMAP features](https://stackoverflow.com/questions/49854767/docker-php7-2-fpm-cant-install-imap-module)
|
||||||
|
* Joomla base used: f9a16bcbd8/4.3/php8.1/apache/Dockerfile
|
||||||
|
|
||||||
|
## Supported Software
|
||||||
|
|
||||||
|
* Joomla
|
||||||
|
* 4 Lights PHP Framework
|
||||||
|
* Matomo
|
||||||
|
|
||||||
|
## Samples included in Repo
|
||||||
|
|
||||||
|
There is a docker-compose, env-sample and php.ini included as sample data.
|
36
docker-compose.yml
Normal file
36
docker-compose.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
# Sample Docker Compose File
|
||||||
|
|
||||||
|
version: "3.3"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
external:
|
||||||
|
name: ${NETWORKNAME}
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mariadb:latest
|
||||||
|
restart: always
|
||||||
|
container_name: "${DBHOST}"
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||||
|
MYSQL_PASSWORD: ${DBPASSWORD}
|
||||||
|
MYSQL_DATABASE: ${DB}
|
||||||
|
MYSQL_USER: ${DBUSER}
|
||||||
|
volumes:
|
||||||
|
- "db:/var/lib/mysql"
|
||||||
|
|
||||||
|
php-app:
|
||||||
|
container_name: "${DOCKERNAME}"
|
||||||
|
image: "4lights/phpcontainer:latest"
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- "./:/data"
|
||||||
|
- ./php.ini:/usr/local/etc/php/php.ini
|
||||||
|
ports:
|
||||||
|
- "${DOCKERPORT}:80"
|
8
env-sample
Normal file
8
env-sample
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
NETWORKNAME=PROXY_NETWORK
|
||||||
|
DBHOST=DB_HOST_NAME
|
||||||
|
MYSQL_ROOT_PASSWORD=ChangeMe
|
||||||
|
DBPASSWORD=ChangeMeAlso
|
||||||
|
DB=DATABASENAME
|
||||||
|
DBUSER=DBUSERNAME
|
||||||
|
DOCKERNAME=Container_name
|
||||||
|
DOCKERPORT=8000
|
128
php.ini
Normal file
128
php.ini
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
[PHP]
|
||||||
|
engine = On
|
||||||
|
short_open_tag = Off
|
||||||
|
precision = 14
|
||||||
|
output_buffering = 4096
|
||||||
|
zlib.output_compression = Off
|
||||||
|
implicit_flush = Off
|
||||||
|
unserialize_callback_func =
|
||||||
|
serialize_precision = -1
|
||||||
|
disable_functions =
|
||||||
|
disable_classes =
|
||||||
|
zend.enable_gc = On
|
||||||
|
zend.exception_ignore_args = On
|
||||||
|
zend.exception_string_param_max_len = 0
|
||||||
|
expose_php = On
|
||||||
|
max_execution_time = 30
|
||||||
|
max_input_time = 60
|
||||||
|
memory_limit = 128M
|
||||||
|
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
|
||||||
|
display_errors = Off
|
||||||
|
display_startup_errors = Off
|
||||||
|
log_errors = On
|
||||||
|
log_errors_max_len = 1024
|
||||||
|
ignore_repeated_errors = Off
|
||||||
|
ignore_repeated_source = Off
|
||||||
|
report_memleaks = On
|
||||||
|
variables_order = "GPCS"
|
||||||
|
request_order = "GP"
|
||||||
|
register_argc_argv = Off
|
||||||
|
auto_globals_jit = On
|
||||||
|
post_max_size = 800M
|
||||||
|
auto_prepend_file =
|
||||||
|
auto_append_file =
|
||||||
|
default_mimetype = "text/html"
|
||||||
|
default_charset = "UTF-8"
|
||||||
|
doc_root =
|
||||||
|
user_dir =
|
||||||
|
enable_dl = Off
|
||||||
|
file_uploads = On
|
||||||
|
upload_max_filesize = 400M
|
||||||
|
max_file_uploads = 20
|
||||||
|
allow_url_fopen = On
|
||||||
|
allow_url_include = Off
|
||||||
|
default_socket_timeout = 60
|
||||||
|
|
||||||
|
[CLI Server]
|
||||||
|
cli_server.color = On
|
||||||
|
|
||||||
|
[Pdo_mysql]
|
||||||
|
pdo_mysql.default_socket=
|
||||||
|
|
||||||
|
[mail function]
|
||||||
|
SMTP = localhost
|
||||||
|
smtp_port = 25
|
||||||
|
mail.add_x_header = Off
|
||||||
|
|
||||||
|
[ODBC]
|
||||||
|
odbc.allow_persistent = On
|
||||||
|
odbc.check_persistent = On
|
||||||
|
odbc.max_persistent = -1
|
||||||
|
odbc.max_links = -1
|
||||||
|
odbc.defaultlrl = 4096
|
||||||
|
odbc.defaultbinmode = 1
|
||||||
|
|
||||||
|
[MySQLi]
|
||||||
|
mysqli.max_persistent = -1
|
||||||
|
mysqli.allow_persistent = On
|
||||||
|
mysqli.max_links = -1
|
||||||
|
mysqli.default_port = 3306
|
||||||
|
mysqli.default_socket =
|
||||||
|
mysqli.default_host =
|
||||||
|
mysqli.default_user =
|
||||||
|
mysqli.default_pw =
|
||||||
|
mysqli.reconnect = Off
|
||||||
|
|
||||||
|
[mysqlnd]
|
||||||
|
mysqlnd.collect_statistics = On
|
||||||
|
mysqlnd.collect_memory_statistics = Off
|
||||||
|
|
||||||
|
[PostgreSQL]
|
||||||
|
pgsql.allow_persistent = On
|
||||||
|
pgsql.auto_reset_persistent = Off
|
||||||
|
pgsql.max_persistent = -1
|
||||||
|
pgsql.max_links = -1
|
||||||
|
pgsql.ignore_notice = 0
|
||||||
|
pgsql.log_notice = 0
|
||||||
|
|
||||||
|
[bcmath]
|
||||||
|
bcmath.scale = 0
|
||||||
|
|
||||||
|
[Session]
|
||||||
|
session.save_handler = files
|
||||||
|
session.use_strict_mode = 0
|
||||||
|
session.use_cookies = 1
|
||||||
|
session.use_only_cookies = 1
|
||||||
|
session.name = PHPSESSID
|
||||||
|
session.auto_start = 0
|
||||||
|
session.cookie_lifetime = 0
|
||||||
|
session.cookie_path = /
|
||||||
|
session.cookie_domain =
|
||||||
|
session.cookie_httponly =
|
||||||
|
session.cookie_samesite =
|
||||||
|
session.serialize_handler = php
|
||||||
|
session.gc_probability = 1
|
||||||
|
session.gc_divisor = 1000
|
||||||
|
session.gc_maxlifetime = 1440
|
||||||
|
session.referer_check =
|
||||||
|
session.cache_limiter = nocache
|
||||||
|
session.cache_expire = 180
|
||||||
|
session.use_trans_sid = 0
|
||||||
|
session.sid_length = 26
|
||||||
|
session.trans_sid_tags = "a=href,area=href,frame=src,form="
|
||||||
|
session.sid_bits_per_character = 5
|
||||||
|
|
||||||
|
[Assertion]
|
||||||
|
zend.assertions = -1
|
||||||
|
|
||||||
|
[Tidy]
|
||||||
|
tidy.clean_output = Off
|
||||||
|
|
||||||
|
[soap]
|
||||||
|
soap.wsdl_cache_enabled=1
|
||||||
|
soap.wsdl_cache_dir="/tmp"
|
||||||
|
soap.wsdl_cache_ttl=86400
|
||||||
|
soap.wsdl_cache_limit = 5
|
||||||
|
|
||||||
|
[ldap]
|
||||||
|
ldap.max_links = -1
|
Loading…
Reference in New Issue
Block a user