From 7076343338ae3439f3c86f01144818abe8c31978 Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Sun, 12 Mar 2023 07:16:23 +0200 Subject: add container helpers; constuct public directory-tree --- Dockerfile | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 Dockerfile (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6c92eb8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,135 @@ +FROM php:8.1-apache as builder + +# ARG MODE="PRODUCTION" +ARG MODE="debug" + +# setup apache +# ------------------------------------------------------------------------------ + +# enable apache mod_rewrite and headers +RUN a2enmod rewrite +RUN a2enmod headers + +# install pdo and mysql for php +RUN docker-php-ext-install pdo pdo_mysql mysqli + +# copy application code +# ------------------------------------------------------------------------------ + +# Copy local code to the container image. +COPY html /var/www/html + +# Copy core files behind public +COPY core /var/www/core + +# Copy configuration files for the container +COPY docker /var/www/docker + +COPY tests /var/www/tests + +COPY composer.json /var/www/ + + +# Install Composer +# ------------------------------------------------------------------------------ + +# Install Composer with required libraries +RUN apt-get update --fix-missing +RUN DEBIAN_FRONTEND=noninteractive apt-get install git unzip wget -y +RUN curl -sS https://getcomposer.org/installer -o composer-setup.php +RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer +RUN rm composer-setup.php + + +# Add Greek locales to server +# ------------------------------------------------------------------------------ +WORKDIR / +RUN apt-get install -y locales +RUN sed -i 's/^# *\(el_GR\)/\1/' /etc/locale.gen +RUN locale-gen + + +# Manage permitions in specific directories +# ------------------------------------------------------------------------------ +# RUN chown -R www-data:www-data /var/www +RUN chmod -R 757 /var/www/html/cache + + +# Use the PORT environment variable in Apache configuration files. +RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf + +# Override with custom settings +# TODO: COPY config/php-ini-overrides.ini $PHP_INI_DIR/conf.d/ + + +# Instal Memcached +# ------------------------------------------------------------------------------ +# RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev && pecl install memcached-3.2.0 && docker-php-ext-enable memcached +# CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] + + +# Install and setup cron +# ------------------------------------------------------------------------------ +# RUN apt-get update && apt-get install cron -y +# RUN crontab -l | { cat; echo "10 * * * * /usr/local/bin/php /var/www/core/cli/cache-categories.php"; } | crontab - +# or? RUN crontab -l | { cat; echo "10 * * * * php /var/www/core/cli/cache-categories.php"; } | crontab - +# ... or copy cronjobs file into/as /etc/cron.d/cron ; then RUN crontab /etc/cron.d/cron +# ... do that while on entrypoint +# (+) run once after ex. 4 minutes + + + +# Install XDebug (only for develop/debud modes) +# ------------------------------------------------------------------------------ +RUN apt-get install -y apt-utils \ + && pecl install xdebug \ + && docker-php-ext-enable xdebug + +COPY docker/config/php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN touch /usr/local/etc/php/xdebug.log +RUN chown www-data:www-data /usr/local/etc/php/xdebug.log +RUN chmod 664 /usr/local/etc/php/xdebug.log + + + +# Prepare the entrypoint as in the original image +# ------------------------------------------------------------------------------ +RUN cp /var/www/docker/bin/docker-entrypoint.sh /usr/local/bin +RUN chmod a+x /usr/local/bin/docker-entrypoint.sh + +ENTRYPOINT [] + + +# TODO: +## Enable OPcache and JIT on production +# ------------------------------------------------------------------------------ +## set environemt variable + +# RUN load OPcache and JIT from script +### if [ "${MODE}" = "PRODUCTION" ]; then +### docker-php-ext-install opcache +### docker-php-ext-install opcache +### mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +### chk: https://stackoverflow.com/questions/68308209/docker-compose-failed-to-solve-rpc-error-code-unknown-desc-failed-to-comp + +# TODO: +# Enable JIT + +### fi + + + +# TODO: +## Enable OPcache and JIT on production +# ------------------------------------------------------------------------------ +### optimize.sh +### #!/bin/bash -x +### +### if test ["$1" == "PRODUCTION"] ; then +### docker-php-ext-install opcache +### docker-php-ext-install opcache +### install and enable JIT +### else +### maybe install some dev-tool +### fi -- cgit v1.2.3