diff --git a/Dockerfile b/Dockerfile index c95b93b..6be2893 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,6 +76,8 @@ RUN \ # Make sure PHP-FPM executes as apache user sed -i 's/user = nobody/user = apache/g' /etc/php7/php-fpm.d/www.conf && \ sed -i 's/group = nobody/group = apache/g' /etc/php7/php-fpm.d/www.conf && \ + # Shortcut cli commands + echo 'alias l="ls -la"; alias s="cd .."' >> ~/.profile && \ # Prepare Apache log dir mkdir -p /var/log/apache2 && \ # Clean base directory @@ -89,8 +91,6 @@ RUN \ RUN chown -R apache:apache /var/www # Make sure apache can read&right to logs RUN chown -R apache:apache /var/log/apache2 -# Apache access to creating pid -RUN chown -R apache:apache /run/apache2 ### Continue execution as Apache user ### USER apache @@ -136,7 +136,11 @@ RUN chown -R apache:apache /var/www # Make sure apache can read&right to logs RUN chown -R apache:apache /var/log/apache2 # Allow apache user login -RUN sed -i 's/apache(.*)\/sbin\/nologin/apache\1\/bin\/ash/g' /etc/passwd +RUN sed -i 's/apache(.*)\/sbin\/nologin/apache\\1\/bin\/ash/g' /etc/passwd # Provide container inside image for data persistence VOLUME ["/var/www"] + +COPY run.sh /run.sh +RUN chmod u+x /run.sh +CMD ["/run.sh"] \ No newline at end of file diff --git a/run.sh b/run.sh index 5fd1e13..43a00c4 100644 --- a/run.sh +++ b/run.sh @@ -1,28 +1,4 @@ #!/bin/sh -# syslog option '-Z' was changed to '-t', change this in /etc/conf.d/syslog so that syslog (and then cron) actually starts -# https://gitlab.alpinelinux.org/alpine/aports/-/issues/9279 -sed -i 's/SYSLOGD_OPTS="-Z"/SYSLOGD_OPTS="-t"/g' /etc/conf.d/syslog -# Restart the syslog -rc-service syslog restart -# Restart the kernel log deamon -rc-service klogd restart - -# Start cron by default -rc-update add crond default && rc-service crond start -# Start Apache by default -rc-update add httpd default && rc-service httpd start -# default PHP-FPM by default -rc-update add php-fpm7 default && rc-service php-fpm7 start - -# Create cron job for Grav maintenance scripts -(crontab -l; echo "* * * * * cd /var/www/html;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab - -# Cron requires that each entry in a crontab end in a newline character. If the last entry in a crontab is missing the newline, cron will consider the crontab (at least partially) broken and refuse to install it. -(crontab -l; echo "") | crontab - - -# Make sure apache can read&right to docroot -chown -R apache:apache /var/www -# Make sure apache can read&right to logs -chown -R apache:apache /var/log/apache2 -# Allow apache user login -sed -i 's/apache(.*)\/sbin\/nologin/apache\1\/bin\/ash/g' /etc/passwd +# Allow Apache to create pid +RUN chown -R apache:apache /run/apache2 \ No newline at end of file