Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
also add Dockerfile.Alpine which is not finished but should install and configure all basic components which are needed
  • Loading branch information
MyUncleSam committed Nov 23, 2020
1 parent 4c21239 commit 4cf8bb2
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ You need to copy the TSI php files into the mounted folder (in this example /roo
| ---- | ----- |
| HTTPS redirect | https://github.com/MyUncleSam/docker-tsi/issues/3 |
| Clickjacking prevention | https://github.com/MyUncleSam/docker-tsi/issues/1 |

# Dockerfile.Alpine
Currently prepared to use it with alpine for a smaller image. But as there is not apache image, we cannot provide all functions. So it is ready but not finished.
14 changes: 7 additions & 7 deletions php-7.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg \
&& docker-php-ext-configure zip \
&& docker-php-ext-install -j$(nproc) gd curl zip bcmath pdo pdo_mysql opcache \
&& wget -O /tmp/ioncube.tar.gz https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz \
&& tar -xvzf /tmp/ioncube.tar.gz --directory=/tmp
&& tar -xvzf /tmp/ioncube.tar.gz --directory=/tmp \
cp /tmp/ioncube/ioncube_loader_lin_7.4.so /php_ext/ioncube.so \
&& PHP_EXT_DIR=$(php-config --extension-dir --extension-dir) \
&& echo "zend_extension = $PHP_EXT_DIR/ioncube.so" > /usr/local/etc/php/conf.d/_ioncube.ini \
&& rm -rf /tmp/*

# ioncube needs to be loaded as first plugin, as they are loaded in alphabetical order, we need to make it the first in line
# also installing and enabling cache extensions and enable mod rewrite
RUN cp /tmp/ioncube/ioncube_loader_lin_7.4.so /php_ext/ioncube.so \
&& PHP_EXT_DIR=$(php-config --extension-dir --extension-dir) \
&& echo "zend_extension = $PHP_EXT_DIR/ioncube.so" > /usr/local/etc/php/conf.d/_ioncube.ini \
&& printf '\n' | pecl install apcu \
RUN printf '\n' | pecl install apcu \
&& printf '\n' | pecl install memcached \
&& printf '\n' | pecl install redis \
&& printf '\n' | pecl install mongodb \
Expand All @@ -57,8 +58,7 @@ RUN echo "#!/bin/bash" > /opt/tsi/cron.sh \
&& echo " echo 'Found cron.php file'" >> /opt/tsi/cron.sh \
&& echo " /usr/local/bin/php /var/www/html/inc/cron.php" >> /opt/tsi/cron.sh \
&& echo "fi" >> /opt/tsi/cron.sh \
&& chmod a+r /opt/tsi/cron.sh \
&& chmod a+x /opt/tsi/cron.sh
&& chmod a+rx /opt/tsi/cron.sh

# add cronjob which is executed every minute
RUN echo "# tsi crontab import file" > /opt/tsi/crontab-file.txt \
Expand Down
88 changes: 88 additions & 0 deletions php-7.4/Dockerfile.Alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# DO NOT USE
# There are still commands for ubuntu and/or apache in this script. But all needed components should be installed and configured correctly
FROM php:7.4-fpm-alpine

# some environment variables
ENV TZ="Europe/Berlin"
ENV MAX_EXECUTION_TIME="60"
ENV MAX_INPUT_TIME="120"
ENV POST_MAX_SIZE="16M"
ENV UPLOAD_MAX_FILESIZE="16M"
ENV MEMORY_LIMIT="512M"
ENV CRON_INTERVAL="* * * * *"

# install dependencies
# set timezone and link extensions directory
# create tsi base folder
RUN apk — no-cache update \
&& apk upgrade \
&& apk add libzip-dev libpng-dev unzip tzdata memcached libmemcached-dev libpng-dev libjpeg gcc curl-dev freetype-dev libjpeg-turbo-dev autoconf build-base \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& ln -s $(php-config --extension-dir --extension-dir) /php_ext \
&& mkdir /opt/tsi

# there is a bug by gd configuration of freetype, it needs to be installed at first to be able to enable freetype
# https://github.com/docker-library/php/issues/926#issuecomment-567230723
# also install ioncube
RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg \
&& docker-php-ext-configure zip \
&& docker-php-ext-install -j$(nproc) gd curl zip bcmath pdo pdo_mysql opcache \
&& wget -O /tmp/ioncube.tar.gz https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz \
&& tar -xvzf /tmp/ioncube.tar.gz --directory=/tmp \
&& cp /tmp/ioncube/ioncube_loader_lin_7.4.so /php_ext/ioncube.so \
&& PHP_EXT_DIR=$(php-config --extension-dir --extension-dir) \
&& echo "zend_extension = $PHP_EXT_DIR/ioncube.so" > /usr/local/etc/php/conf.d/_ioncube.ini \
&& rm -rf /tmp/

# ioncube needs to be loaded as first plugin, as they are loaded in alphabetical order, we need to make it the first in line
# also installing and enabling cache extensions and enable mod rewrite
RUN printf '\n' | pecl install apcu \
&& printf '\n' | pecl install memcached \
&& printf '\n' | pecl install redis \
&& printf '\n' | pecl install mongodb \
&& PHP_EXT_DIR=$(php-config --extension-dir --extension-dir) && echo "extension=$PHP_EXT_DIR/memcached.so" > /usr/local/etc/php/conf.d/cache-extensions.ini \
&& PHP_EXT_DIR=$(php-config --extension-dir --extension-dir) && echo "extension=$PHP_EXT_DIR/apcu.so" >> /usr/local/etc/php/conf.d/cache-extensions.ini \
&& PHP_EXT_DIR=$(php-config --extension-dir --extension-dir) && echo "extension=$PHP_EXT_DIR/redis.so" >> /usr/local/etc/php/conf.d/cache-extensions.ini \
&& PHP_EXT_DIR=$(php-config --extension-dir --extension-dir) && echo "extension=$PHP_EXT_DIR/mongodb.so" >> /usr/local/etc/php/conf.d/cache-extensions.ini \
&& /usr/sbin/a2enmod rewrite

# php configuration
RUN echo "max_execution_time = ${MAX_EXECUTION_TIME}" > /usr/local/etc/php/conf.d/tsi-config.ini \
&&echo "max_input_time = ${MAX_INPUT_TIME}" >> /usr/local/etc/php/conf.d/tsi-config.ini \
&& echo "post_max_size = ${POST_MAX_SIZE}" >> /usr/local/etc/php/conf.d/tsi-config.ini \
&& echo "upload_max_filesize = ${UPLOAD_MAX_FILESIZE}" >> /usr/local/etc/php/conf.d/tsi-config.ini \
&& echo "allow_url_fopen = on" >> /usr/local/etc/php/conf.d/tsi-config.ini \
&& echo "memory_limit = ${MEMORY_LIMIT}" >> /usr/local/etc/php/conf.d/tsi-config.ini

# create cronjob file to only execute if cron.php is available
RUN echo "#!/bin/sh" > /opt/tsi/cron.sh \
&& echo "" >> /opt/tsi/cron.sh \
&& echo "if [ -f /var/www/html/inc/cron.php ]; then" >> /opt/tsi/cron.sh \
&& echo " echo 'Found cron.php file'" >> /opt/tsi/cron.sh \
&& echo " /usr/local/bin/php /var/www/html/inc/cron.php" >> /opt/tsi/cron.sh \
&& echo "fi" >> /opt/tsi/cron.sh \
&& chmod a+r /opt/tsi/cron.sh \
&& chmod a+x /opt/tsi/cron.sh

# add cronjob which is executed every minute
RUN echo "# tsi crontab import file" > /opt/tsi/crontab-file.txt \
&& echo "${CRON_INTERVAL} /opt/tsi/cron.sh > /dev/null 2>&1" >> /opt/tsi/crontab-file.txt \
&& crontab -u www-data /opt/tsi/crontab-file.txt

# custom startscript to modify permissions
RUN echo "#!/bin/sh" > /opt/tsi/start.sh \
&& echo "chown -c -R www-data: /var/www/html" >> /opt/tsi/start.sh \
&& echo "cron &" >> /opt/tsi/start.sh \
&& echo "apache2-foreground" >> /opt/tsi/start.sh \
&& chmod u+x /opt/tsi/start.sh

# cleanup
RUN rm /php_ext \
&& rm -rf /tmp/* \
&& rm /opt/tsi/crontab-file.txt

# volumes
VOLUME ["/var/www/html", "/var/www/html"]

# entrypoint
CMD ["/opt/tsi/start.sh"]

0 comments on commit 4cf8bb2

Please sign in to comment.