Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM php:7.4-apache

# Build Environment Variables
ENV VERSION 3.5.2
ENV URL https://github.com/phpservermon/phpservermon/archive/v${VERSION}.tar.gz
ENV URL https://github.com/phpservermon/phpservermon/archive/v${VERSION}.tar.gz

# Install Base
RUN apt-get update
Expand All @@ -30,6 +30,7 @@ RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf
ENV PSM_REFRESH_RATE_SECONDS 90
ENV PSM_AUTO_CONFIGURE true
ENV PSM_PHP_DEBUG false
ENV PSM_BASE_URL false
ENV MYSQL_HOST database
ENV MYSQL_USER phpservermonitor
ENV MYSQL_PASSWORD YOUR_PASSWORD
Expand Down Expand Up @@ -57,11 +58,11 @@ RUN set -ex; \
cd /tmp; \
rm -rf ${APACHE_DOCUMENT_ROOT}/*; \
curl --output phpservermonitor.tar.gz --location $URL; \
tar -xvf phpservermonitor.tar.gz --strip-components=1 -C ${APACHE_DOCUMENT_ROOT}/; \
tar -xvf phpservermonitor.tar.gz --strip-components=1 -C ${APACHE_DOCUMENT_ROOT}/; \
cd ${APACHE_DOCUMENT_ROOT}
# chown -R ${APACHE_RUN_USER}:www-data /var/www
# find /var/www -type d -exec chmod 750 {} \; ; \
# find /var/www -type f -exec chmod 640 {} \;
# find /var/www -type f -exec chmod 640 {} \;

# Configuration
# VOLUME ${APACHE_DOCUMENT_ROOT}/config.php
Expand All @@ -76,5 +77,7 @@ COPY docker-entrypoint.sh /usr/local/bin/
COPY maria-wait.sh /usr/local/bin/

RUN chmod u+rwx /usr/local/bin/docker-entrypoint.sh
RUN chmod u+rwx /usr/local/bin/maria-wait.sh

ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]
CMD ["apache2-foreground"]
8 changes: 6 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
# Setup Database Connection
if [ ${PSM_AUTO_CONFIGURE} = true ]; then

# Setup / Create
# Setup / Create
echo "Auto Configure / Create config.php"
touch ${APACHE_DOCUMENT_ROOT}/config.php; \
chmod 0777 ${APACHE_DOCUMENT_ROOT}/config.php
Expand All @@ -20,6 +20,10 @@ define('PSM_DB_PREFIX', '${MYSQL_DATABASE_PREFIX}');
?>
EOF

if [ ${PSM_BASE_URL} != false ]; then
sed -i "s|?>|define('PSM_BASE_URL', '$PSM_BASE_URL');\n?>|1" ${APACHE_DOCUMENT_ROOT}/config.php
fi

else
# Setup Database Connection Defaults
echo "Setting Database Connection Defaults"
Expand Down Expand Up @@ -60,4 +64,4 @@ fi

# Start CMD Commands
exec "$@" & (while true; do sleep "${PSM_REFRESH_RATE_SECONDS}"; /usr/local/bin/php ${APACHE_DOCUMENT_ROOT}/cron/status.cron.php; done)
#exec "$@" & (while true; do sleep ${PSM_REFRESH_RATE_SECONDS}; su -l www-data -s /usr/local/bin/php ${APACHE_DOCUMENT_ROOT}/cron/status.cron.php; done)
#exec "$@" & (while true; do sleep ${PSM_REFRESH_RATE_SECONDS}; su -l www-data -s /usr/local/bin/php ${APACHE_DOCUMENT_ROOT}/cron/status.cron.php; done)
2 changes: 1 addition & 1 deletion maria-wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -ueo pipefail

echo -n "Waiting until MariaDB has started"
until (timeout 1 bash -c "< /dev/tcp/db/3306") &> /dev/null; do
until (timeout 1 bash -c "< /dev/tcp/${MYSQL_HOST}/3306") &> /dev/null; do
echo -n .
sleep 1
done
Expand Down