Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PSM_BASE_URL as possible environment variable #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
9 changes: 6 additions & 3 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"]
6 changes: 5 additions & 1 deletion 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the 1 for? I've never seen that before.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it means replace first ocurrence only
it was in the sed command I copied from so I just left it.
g would also work obviously

fi

else
# Setup Database Connection Defaults
echo "Setting Database Connection Defaults"
Expand Down