Sign inSign up

oberd/php-7.4-apache

By oberd

Updated over 2 years ago

Image
2

6.2K

oberd/php-7.4-apache repository overview

PHP 7.4 Apache Base Image

This base image contains some helper functionality to get a basic PHP project up and running. It utilizes Task and contains some basic tasks to preform common functionality.

Pre-installed PHP Extensions

The following PHP extensions are installed into this base image by default. You can view the modules by running docker run oberd/php-7.4-apache php -m

To include additional extensions, follow the steps from the official PHP base image documentation. Although, You should consider if the extension should be added to the base image or your project specific Dockerfile.

[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
soap
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]
Usage

The usage folder folder contains an example Dockerfile and Taskfile.yml that you can include in your project to get up and running.

Helpers
Commands

If you're making a development stage of a multi-stage Dockerfile and want to enable Xdebug (should not be enabled in a production environment), you can add the following line to your development stage. It will install and enable the xdebug extension.

RUN enable-xdebug
Taskfile

The following tasks to be ran in a Taskfile are already pre-configured in /usr/local/tasks/ for usage in your projects. Check the sample Taskfile.yml for a standard usage in a Laravel environment.

Apache
start

This task will start Apache in the foreground

task -t tasks/apache.yml start

Laravel
routes

This task will cache your Laravel routes. Should only really be used in a production environment.

task -t tasks/laravel.yml cache

migrate

This task will run your Laravel migrations using the --force flag.

task -t tasks/laravel.yml migrate

Composer

The Composer tasks should really only be ran in a development environment where the vendor directory may be volume mounted and cannot be included into the Docker image itself. A production image should contain the installed vendor directory within the image for consistency.

configure

This task will configure composer with your Github OAuth token to allow access to private repositories and not be rate limited.

Requires: the environment variable GITHUB_OAUTH_TOKEN to be set.

task -t tasks/composer.yml configure

install

This task is dependent upon the configure task being ran. It will run composer install.

task -t tasks/composer.yml install

PHP
xdebug-host

This task will configure the Xdebug remote host into the Xdebug config.

Optional: the environment variable XDEBUG_HOST_IP can be set. Else, it will default to 10.254.254.254

Sites

Using the built in Apache commands a2ensite and a2dissite to enable and disable site configurations, this base image contains pre-defined configurations for some standard PHP frameworks.

Laravel

To configure a standard Laravel project your code to /var/www/app and this configuration will point the DocumentRoot to the public folder /var/www/app/public

RUN a2ensite laravel
COPY --chown=www-data:www-data . /var/www/app
Considerations
Apache Keep Alive Timeout

The Apache KeepAliveTimeout is set to 65 within this base image. The reason for this is because it is very likely you are using this image behind an AWS Load Balancer and the default idle timeout for them is 60 seconds.

Following the guidance in the AWS Docs that states

When the keep-alive option is enabled, choose a longer keep-alive timeout than the load balancer idle timeout.

This will prevent errors such as 502 Bad Gateway where the server closes the connection to the load balancer before it is expecting.

If you need to change the KeepAliveTimeout for your use case you can add the following line to your Dockerfile

RUN sed -ri -e 's!KeepAliveTimeout .*!KeepAliveTimeout 10!g' /etc/apache2/apache2.conf

(Replacing 10 with whatever you want the timeout to be)

Tag summary

Content type

Image

Digest

sha256:6a26855a0

Size

35.6 MB

Last updated

over 2 years ago

docker pull oberd/php-7.4-apache