Skip to content
Snippets Groups Projects
Commit 68d662d8 authored by Elian Loraux's avatar Elian Loraux
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
*
!docker-entrypoint.sh
!maria-wait.sh
COMPOSE_FILE=docker-compose.yml:traefik.ym
MYSQL_PASSWORD=need_to_fill
MYSQL_ROOT_PASSWORD=need_to_fill
mariadb
.env
FROM php:8.2-apache
# MAINTAINER Austin St. Aubin <austinsaintaubin@gmail.com>
# Build Environment Variables
ENV VERSION 3.5.2
ENV URL https://github.com/phpservermon/phpservermon/archive/v${VERSION}.tar.gz
# Install Base
RUN apt-get update
# Install & Setup Dependencies
RUN set -ex; \
apt-get install -y curl iputils-ping; \
apt-get install -y zip unzip git; \
#docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-webp-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr; \
docker-php-ext-install pdo pdo_mysql mysqli sockets; \
apt-get clean -y; \
rm -rf /var/lib/apt/lists/*; \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Expose Ports
EXPOSE 80
# Apache Document Root
ENV APACHE_DOCUMENT_ROOT /var/www/html
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# User Environment Variables
ENV PSM_REFRESH_RATE_SECONDS 90
ENV PSM_AUTO_CONFIGURE true
ENV PSM_PHP_DEBUG false
ENV MYSQL_HOST database
ENV MYSQL_USER phpservermonitor
ENV MYSQL_PASSWORD YOUR_PASSWORD
ENV MYSQL_DATABASE phpservermonitor
ENV MYSQL_DATABASE_PREFIX psm_
# Time Zone
ENV PHP_TIME_ZONE 'Europe/Amsterdam'
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN sed -i 's/;date.timezone =/date.timezone = "${PHP_TIME_ZONE}"/g' "$PHP_INI_DIR/php.ini"
# RUN php -i | grep -i error
# Webserver Run User
ENV APACHE_RUN_USER www-data
# Persistent Sessions
RUN mkdir '/sessions'; \
chown ${APACHE_RUN_USER}:www-data '/sessions'; \
sed -i 's/;session.save_path\s*=.*/session.save_path = "\/sessions"/g' "$PHP_INI_DIR/php.ini"; \
cat "$PHP_INI_DIR/php.ini" | grep 'session.save_path'
VOLUME /sessions
# Extract Repo HTML Files
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}/; \
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 {} \;
# Configuration
# VOLUME ${APACHE_DOCUMENT_ROOT}/config.php
RUN touch ${APACHE_DOCUMENT_ROOT}/config.php; \
chmod 0777 ${APACHE_DOCUMENT_ROOT}/config.php
# Composer install dependencies
RUN composer install --no-dev -o
# Add Entrypoint & Start Commands
COPY docker-entrypoint.sh /usr/local/bin/
COPY maria-wait.sh /usr/local/bin/
RUN chmod u+rwx /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]
# PHPServerMonitor Tetrix
New version of dockerized [php servermonitor](https://github.com/phpservermon/phpservermon)
Based on [docker php servermonitor](https://github.com/phpservermon/docker-phpservermonitor)
## Install
```bash
git clone gitlab@gitlab.tetras-libre.fr:nocloud/docker/phpservermonitor.git
cd phpservermonitor
cp .env.sample .env
```
Change `MYSQL_PASSWORD` and `MYSQL_ROOT_PASSWORD` in .env
version: '3.8'
services:
phpservermonitor:
build: .
image: phpservermonitor:latest
container_name: phpservermonitor
restart: always
environment:
- TIME_ZONE='Europe/Amsterdam'
- PSM_REFRESH_RATE_SECONDS=15
- PSM_AUTO_CONFIGURE=true
- MYSQL_HOST=db
- MYSQL_USER=phpservermonitor
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_DATABASE=phpservermonitor
- MYSQL_DATABASE_PREFIX=psm_
ports:
- 8080:80
volumes:
- /sessions
depends_on:
- db
db:
image: mariadb
container_name: phpservermonitor_mariadb
restart: always
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_USER=phpservermonitor
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_DATABASE=phpservermonitor
volumes:
- ./mariadb:/var/lib/mysql/phpservermonitor
#!/bin/sh
set -e
# Setup Database Connection
if [ ${PSM_AUTO_CONFIGURE} = true ]; then
# Setup / Create
echo "Auto Configure / Create config.php"
touch ${APACHE_DOCUMENT_ROOT}/config.php; \
chmod 0777 ${APACHE_DOCUMENT_ROOT}/config.php
cat > ${APACHE_DOCUMENT_ROOT}/config.php << EOF
<?php
define('PSM_DB_HOST', '${MYSQL_HOST}');
define('PSM_DB_PORT', '');
define('PSM_DB_USER', '${MYSQL_USER}');
define('PSM_DB_PASS', '${MYSQL_PASSWORD}');
define('PSM_DB_NAME', '${MYSQL_DATABASE}');
define('PSM_DB_PREFIX', '${MYSQL_DATABASE_PREFIX}');
?>
EOF
else
# Setup Database Connection Defaults
echo "Setting Database Connection Defaults"
sed -ri -e "/db_host/s/'[^']*'/'${MYSQL_HOST}'/2" "${APACHE_DOCUMENT_ROOT}/src/psm/Module/Install/Controller/InstallController.php"
sed -ri -e "/db_port/s/'[^']*'/''/2" "${APACHE_DOCUMENT_ROOT}/src/psm/Module/Install/Controller/InstallController.php"
sed -ri -e "/db_name/s/'[^']*'/'${MYSQL_DATABASE}'/2" "${APACHE_DOCUMENT_ROOT}/src/psm/Module/Install/Controller/InstallController.php"
sed -ri -e "/db_user/s/'[^']*'/'${MYSQL_USER}'/2" "${APACHE_DOCUMENT_ROOT}/src/psm/Module/Install/Controller/InstallController.php"
sed -ri -e "/db_pass/s/'[^']*'/'${MYSQL_PASSWORD}'/2" "${APACHE_DOCUMENT_ROOT}/src/psm/Module/Install/Controller/InstallController.php"
sed -ri -e "/db_prefix/s/'[^']*'/'${MYSQL_DATABASE_PREFIX}'/2" "${APACHE_DOCUMENT_ROOT}/src/psm/Module/Install/Controller/InstallController.php"
fi
# Setup Database Connection
if [ ${PSM_PHP_DEBUG} = true ]; then
# PHP Debugging
cat > ${APACHE_DOCUMENT_ROOT}/phpinfo.php << EOF
<?php echo exec('whoami'); ?>
<?php
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
ini_set('error_log','script_errors.log');
ini_set('log_errors','On');
phpinfo();
?>
EOF
fi
# wait until mariadb is ready
echo "Waiting until database is ready..."
/usr/local/bin/maria-wait.sh
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- apache2-foreground "$@"
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)
#!/bin/bash
set -ueo pipefail
echo -n "Waiting until MariaDB has started"
until (timeout 1 bash -c "< /dev/tcp/db/3306") &> /dev/null; do
echo -n .
sleep 1
done
echo
version: "3"
services:
kasm:
networks:
- default
- traefik
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.${NAME}.rule=Host(`${HOST}`)"
- "traefik.http.routers.${NAME}.tls.certresolver=myresolver"
- "traefik.http.routers.${NAME}.entrypoints=web,websecure"
- "traefik.http.services.${NAME}.loadbalancer.server.port=6901"
- "traefik.http.services.${NAME}.loadbalancer.server.scheme=https"
networks:
traefik:
external: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment