traefik_typo3/Dockerfile

158 lines
4.7 KiB
Docker
Raw Normal View History

2023-11-26 12:24:49 +01:00
# Dockerfile
# Docker image for TYPO3 CMS
FROM php:8.2-apache
LABEL maintainer="Raphael Martin <raphy.martin@protonmail.ch>"
2023-11-28 20:59:53 +01:00
# set envirement
2023-11-29 12:13:26 +01:00
ENV LANG=de_AT.UTF-8
2023-11-26 12:24:49 +01:00
ENV APACHE_RUN_USER a2g-www
ENV TYPO3_VERSION 12.4.8
ENV TYPO3_SHA256CHECKSUM 8293b3441ec133fc8f9174fab5b88f450044ded0e188a0f12de37ad60a8bf8b3
# change apache user
RUN adduser --uid 1000 --gecos 'Apache User' --disabled-password $APACHE_RUN_USER \
&& chown -R "$APACHE_RUN_USER:$APACHE_RUN_USER" /var/lock/apache2 /var/run/apache2
# update system
RUN apt-get update -y && apt-get upgrade -y
2023-11-28 20:59:53 +01:00
# Install wget and locales
2023-11-26 12:24:49 +01:00
RUN apt-get install -y --no-install-recommends \
wget \
2023-11-28 20:59:53 +01:00
locales
RUN export LANG=${LANG} && \
2023-11-29 12:13:26 +01:00
export LC_ALL=${LANG} && \
export LC_TIME=${LANG} && \
export LANGUAGE=${LANG} && \
echo "${LANG} UTF-8" > /etc/locale.gen && \
2023-11-28 20:59:53 +01:00
/usr/sbin/locale-gen
# Export env vars
RUN { \
2023-11-29 12:13:26 +01:00
echo "export LC_ALL=${LANG}"; \
echo "export LANG=${LANG}"; \
echo "export LANGUAGE=${LANG}"; \
2023-11-28 20:59:53 +01:00
} >> ~/.bashrc
RUN cp ~/.bashrc /home/${APACHE_RUN_USER} && \
chown -R "$APACHE_RUN_USER:$APACHE_RUN_USER" /home/${APACHE_RUN_USER}/.bashrc
# Download TYPO3
RUN cd /tmp && \
wget -O download.tar.gz https://get.typo3.org/${TYPO3_VERSION} && \
echo "${TYPO3_SHA256CHECKSUM} /tmp/download.tar.gz" > /tmp/download.tar.gz.sum
RUN sha256sum -c "/tmp/download.tar.gz.sum"
# Install
RUN set -ex; \
\
apt-get install -y --no-install-recommends \
2023-11-26 12:24:49 +01:00
# Configure PHP
2023-11-28 20:59:53 +01:00
libxml2-dev \
libfreetype6-dev \
2023-11-26 12:24:49 +01:00
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
libpq-dev \
zlib1g-dev \
sendmail \
2023-11-28 20:59:53 +01:00
graphicsmagick
2023-11-29 12:13:26 +01:00
RUN docker-php-ext-configure gd --with-libdir=/usr/include/ --with-jpeg --with-freetype
2023-11-28 20:59:53 +01:00
RUN docker-php-ext-install -j$(nproc) \
2023-11-29 12:13:26 +01:00
pdo \
2023-11-28 20:59:53 +01:00
pdo_mysql \
soap \
gd \
opcache \
intl
2023-11-26 12:24:49 +01:00
RUN apt-get -y purge \
libxml2-dev libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
2023-11-29 12:13:26 +01:00
zlib1g-dev \
wget && \
apt-get autoremove -y
RUN apt-get install -y --no-install-recommends \
2023-11-26 12:24:49 +01:00
libzip-dev \
2023-11-29 12:13:26 +01:00
zip
RUN docker-php-ext-install -j$(nproc) \
zip
2023-11-26 12:24:49 +01:00
2023-11-29 12:13:26 +01:00
# Clean
RUN apt-get -y purge \
libzip-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /usr/src/*
2023-11-26 12:24:49 +01:00
2023-11-29 12:13:26 +01:00
# Configure Apache
2023-11-26 12:24:49 +01:00
2023-11-28 20:59:53 +01:00
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'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
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
RUN set -eux; \
2023-11-29 12:13:26 +01:00
a2enmod rewrite expires remoteip headers; \
2023-11-28 20:59:53 +01:00
{ \
echo 'RemoteIPHeader X-Forwarded-For'; \
# these IP ranges are reserved for "private" use and should thus *usually* be safe inside Docker
echo 'RemoteIPInternalProxy 10.0.0.0/8'; \
echo 'RemoteIPInternalProxy 172.16.0.0/12'; \
echo 'RemoteIPInternalProxy 192.168.0.0/16'; \
echo 'RemoteIPInternalProxy 169.254.0.0/16'; \
echo 'RemoteIPInternalProxy 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' '{}' +
# install TYPO3 surf
# RUN mkdir /usr/local/surf && \
# curl -L https://github.com/TYPO3/Surf/releases/download/3.4.6/surf.phar -o /usr/local/surf/surf.phar && \
# chmod +x /usr/local/surf/surf.phar && \
# ln -s /usr/local/surf/surf.phar /usr/local/bin/surf
2023-11-29 12:13:26 +01:00
# install TYPO3
2023-11-26 12:24:49 +01:00
RUN tar -xzf /tmp/download.tar.gz -C /var/www/ && \
rm /tmp/download*
2023-11-28 20:59:53 +01:00
2023-11-26 12:24:49 +01:00
RUN cd /var/www/html && \
ln -s ../typo3_src-* typo3_src && \
ln -s typo3_src/index.php && \
2023-11-29 12:13:26 +01:00
ln -s typo3_src/typo3
2023-11-28 20:59:53 +01:00
2023-11-26 12:24:49 +01:00
RUN chown -R $APACHE_RUN_USER:$APACHE_RUN_USER /var/www/html && \
2023-11-28 20:59:53 +01:00
chown -R $APACHE_RUN_USER:$APACHE_RUN_USER /var/www/typo3_src-* && \
chown -R root:root /etc/apache2/sites-enabled
RUN { \
echo "ServerSignature Off"; \
echo "ServerTokens Prod"; \
} >> /etc/apache2/apache2.conf
VOLUME /var/www