Updates
This commit is contained in:
parent
7194097708
commit
fff99721a0
84
Dockerfile
84
Dockerfile
|
|
@ -1,52 +1,41 @@
|
||||||
FROM php:7.4-fpm
|
FROM alpine
|
||||||
|
|
||||||
# Ubuntu repo updates
|
# Initial updates
|
||||||
RUN apt-get update
|
RUN apk update && \
|
||||||
|
apk upgrade && \
|
||||||
|
rm -rf /var/cache/apk/* /var/log/*
|
||||||
|
|
||||||
# Install dependencies
|
# Install packages
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apk add apache2 apache2-proxy composer zip curl
|
||||||
apt-utils \
|
|
||||||
apache2 \
|
|
||||||
unzip \
|
|
||||||
libfreetype6-dev \
|
|
||||||
libjpeg62-turbo-dev \
|
|
||||||
libpng-dev \
|
|
||||||
libyaml-dev \
|
|
||||||
libzip4 \
|
|
||||||
libzip-dev \
|
|
||||||
zlib1g-dev \
|
|
||||||
libicu-dev \
|
|
||||||
libmemcached11 \
|
|
||||||
libmemcachedutil2 \
|
|
||||||
build-essential \
|
|
||||||
libmemcached-dev \
|
|
||||||
g++ \
|
|
||||||
git \
|
|
||||||
cron \
|
|
||||||
vim \
|
|
||||||
&& docker-php-ext-install opcache \
|
|
||||||
&& docker-php-ext-configure intl \
|
|
||||||
&& docker-php-ext-install intl \
|
|
||||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
|
||||||
&& docker-php-ext-install -j$(nproc) gd \
|
|
||||||
&& docker-php-ext-install zip \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Enable Apache Rewrite + Expires Module
|
# Configure to use php fpm and don't use /var/www to store everything (modules and logs)
|
||||||
RUN a2enmod rewrite expires && \
|
RUN sed -i 's/LoadModule mpm_prefork_module/#LoadModule mpm_prefork_module/g' /etc/apache2/httpd.conf && \
|
||||||
sed -i 's/ServerTokens OS/ServerTokens ProductOnly/g' \
|
sed -i 's/#LoadModule mpm_event_module/LoadModule mpm_event_module/g' /etc/apache2/httpd.conf && \
|
||||||
/etc/apache2/conf-available/security.conf
|
sed -i 's/#LoadModule rewrite_module/LoadModule rewrite_module/g' /etc/apache2/httpd.conf && \
|
||||||
|
# remove useless module bundled with proxy
|
||||||
|
sed -i 's/LoadModule lbmethod/#LoadModule lbmethod/g' /etc/apache2/conf.d/proxy.conf && \
|
||||||
|
# change ServerRoot
|
||||||
|
sed -i 's/var\/www\/localhost\/htdocs/var\/www/g' /etc/apache2/httpd.conf && \
|
||||||
|
sed -i 's/ServerRoot \/var\/www/ServerRoot \/usr\/local\/apache/g' /etc/apache2/httpd.conf && \
|
||||||
|
# change user and group
|
||||||
|
sed -i 's/^User apache/User www-data/g' /etc/apache2/httpd.conf && \
|
||||||
|
sed -i 's/^Group apache/Group www-data/g' /etc/apache2/httpd.conf && \
|
||||||
|
# Prepare env and create user
|
||||||
|
mkdir -p /var/log/apache2 && \
|
||||||
|
groupdel www-data && \
|
||||||
|
groupmod -g 101 -n www-data apache && \
|
||||||
|
usermod -g 101 -u 100 -l www-data -d /var/www apache && \
|
||||||
|
chown www-data:www-data /var/log/apache2 /var/www && \
|
||||||
|
# Clean base directory and create required ones
|
||||||
|
rm -rf /var/www/* && \
|
||||||
|
mkdir -p /run/apache2 /usr/local/apache && \
|
||||||
|
ln -s /usr/lib/apache2 /usr/local/apache/modules && \
|
||||||
|
ln -s /var/log/apache2 /usr/local/apache/logs
|
||||||
|
|
||||||
# Install composer
|
COPY vhost.conf /etc/apache2/conf.d/vhost.conf
|
||||||
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
||||||
|
|
||||||
RUN pecl install apcu \
|
ENV APACHE_UID 100
|
||||||
&& pecl install yaml-2.1.0 \
|
ENV APACHE_GID 101
|
||||||
&& docker-php-ext-enable apcu yaml gd opcache intl zip
|
|
||||||
|
|
||||||
# Set user to www-data
|
|
||||||
RUN chown www-data:www-data /var/www
|
|
||||||
USER www-data
|
|
||||||
|
|
||||||
# Define Grav specific version of Grav or use latest stable
|
# Define Grav specific version of Grav or use latest stable
|
||||||
ENV GRAV_VERSION latest
|
ENV GRAV_VERSION latest
|
||||||
|
|
@ -68,6 +57,9 @@ EXPOSE 80/tcp
|
||||||
USER root
|
USER root
|
||||||
|
|
||||||
# provide container inside image for data persistence
|
# provide container inside image for data persistence
|
||||||
VOLUME ["/var/www/html"]
|
VOLUME ["/var/www"]
|
||||||
|
|
||||||
CMD ["sh", "-c", "apache2-foreground"]
|
COPY run.sh /run.sh
|
||||||
|
RUN chmod u+x /run.sh
|
||||||
|
|
||||||
|
CMD ["/run.sh"]
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/sh
|
||||||
|
CURRENT_APACHE_ID=$(id -u www-data)
|
||||||
|
if [ "$CURRENT_APACHE_ID" != "$APACHE_UID" ]; then
|
||||||
|
echo "Fixing permissions for www-data"
|
||||||
|
usermod -u $APACHE_UID www-data
|
||||||
|
groupmod -g $APACHE_GID www-data
|
||||||
|
chown -R www-data:www-data /run/apache2 /var/www
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec /usr/sbin/httpd -DFOREGROUND;
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
ServerName localhost
|
||||||
|
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName localhost
|
||||||
|
|
||||||
|
## Vhost docroot
|
||||||
|
DocumentRoot /var/www
|
||||||
|
|
||||||
|
## Take .htaccess.local in priority
|
||||||
|
AccessFileName .htaccess.local .htaccess
|
||||||
|
|
||||||
|
## PHP-FPM connection
|
||||||
|
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/$1
|
||||||
|
DirectoryIndex index.php
|
||||||
|
|
||||||
|
## Directories,
|
||||||
|
<LocationMatch "^(.*/)\..*">
|
||||||
|
Require all denied
|
||||||
|
</LocationMatch>
|
||||||
|
|
||||||
|
<FilesMatch "^\.">
|
||||||
|
Require all denied
|
||||||
|
</FilesMatch>
|
||||||
|
|
||||||
|
<DirectoryMatch "^(.*/)\..*">
|
||||||
|
Require all denied
|
||||||
|
</DirectoryMatch>
|
||||||
|
|
||||||
|
<Directory "/var/www">
|
||||||
|
Options -Indexes +FollowSymLinks +IncludesNOEXEC -MultiViews
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
|
||||||
|
<FilesMatch ".+(\.php)$">
|
||||||
|
SetHandler "proxy:fcgi://php:9000"
|
||||||
|
</FilesMatch>
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Proxy "fcgi://php:9000">
|
||||||
|
ProxySet timeout=1200
|
||||||
|
</Proxy>
|
||||||
|
|
||||||
|
## Logging : hide version
|
||||||
|
ServerSignature Off
|
||||||
|
</VirtualHost>
|
||||||
Loading…
Reference in New Issue