Cleanup of php-fpm and related components

This commit is contained in:
Christoph Kluge 2022-03-30 15:54:56 +02:00
parent e3d91ba9cb
commit cb420305ab
15 changed files with 49 additions and 2368 deletions

25
.env
View File

@ -1,23 +1,6 @@
########################################################################
# CLUSTERCOCKPIT SETTINGS
# CCBACKEND DEVEL DOCKER SETTINGS
########################################################################
CLUSTERCOCKPIT_BRANCH=develop
APP_CLUSTERCOCKPIT_INIT=true
APP_ENVIRONMENT=dev
APP_SECRET=67d829bf61dc5f87a73fd814e2c9f629
APP_JWT_PRIV_KEY="dtPC/6dWJFKZK7KZ78CvWuynylOmjBFyMsUWArwmodOTN9itjL5POlqdZkcnmpJ0yPm4pRaCrvgFaFAbpyik/Q=="
APP_JWT_PUB_KEY="kzfYrYy+TzpanWZHJ5qSdMj5uKUWgq74BWhQG6copP0="
########################################################################
# PHP
########################################################################
PHP_XDEBUG_INIT=false
PHP_XDEBUG_MODE=debug,develop
PHP_XDEBUG_CLIENT_PORT=9003
#> LINUX: 'docker0' interface IP of host
# PHP_XDEBUG_CLIENT_HOST=1.2.3.4
#> MAC/WIN: Docker Wildcard for host IP
PHP_XDEBUG_CLIENT_HOST=host.docker.internal
########################################################################
# MySQL
@ -51,12 +34,6 @@ LDAP_DOMAIN=rrze.uni-erlangen.de
########################################################################
PHPMYADMIN_PORT=8080
########################################################################
# NGINX
########################################################################
NGINX_PORT=80
NGINX_SYMFONY_SERVER_NAME=localhost
########################################################################
# INTERNAL SETTINGS
########################################################################

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
if [ -d symfony ]; then
if [ -d influxdb ]; then
echo "Data already initialized!"
echo -n "Perform a fresh initialisation? [yes to proceed / no to exit] "
read -r answer
@ -16,16 +16,12 @@ if [ -d symfony ]; then
fi
fi
mkdir symfony
# Download example job job-archive
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/job-archive.tar.xz
tar xJf job-archive.tar.xz
rm ./job-archive.tar.xz
# 101 is the uid and gid of the user and group www-data in the cc-php container running php-fpm.
# For a demo with no new jobs it is enough to give www read permissions on that directory.
# echo "This script needs to chown the job-archive directory so that the application can write to it:"
# sudo chown -R 82:82 ./job-archive
# Download data for influxdb2
mkdir -p influxdb/data
wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/influxdbv2-data.tar.xz
cd influxdb/data

View File

@ -6,6 +6,17 @@ services:
- "4222:4222"
- "8222:8222"
cc-metric-store:
container_name: cc-metric-store
build:
context: ./cc-metric-store
ports:
- "8081:8081"
volumes:
- ${DATADIR}/cc-metric-store:/data
depends_on:
- nats
db:
container_name: cc-db
image: mysql:8.0.22
@ -15,12 +26,26 @@ services:
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "127.0.0.1:3336:3306"
volumes:
- ${DATADIR}/sql-init:/docker-entrypoint-initdb.d
# - ${DATADIR}/sqldata:/var/lib/mysql
cap_add:
- SYS_NICE
phpmyadmin:
container_name: cc-phpmyadmin
image: phpmyadmin
environment:
- PMA_HOST=cc-db
- PMA_USER=root
- PMA_PASSWORD=${MYSQL_ROOT_PASSWORD}
ports:
- "127.0.0.1:${PHPMYADMIN_PORT}:80"
depends_on:
- db
influxdb:
container_name: cc-influxdb
image: influxdb
@ -39,17 +64,6 @@ services:
- ${DATADIR}/influxdb/data:/var/lib/influxdb2
- ${DATADIR}/influxdb/config:/etc/influxdb2
cc-metric-store:
container_name: cc-metric-store
build:
context: ./cc-metric-store
ports:
- "8081:8081"
volumes:
- ${DATADIR}/cc-metric-store:/data
depends_on:
- nats
openldap:
container_name: cc-ldap
image: osixia/openldap:1.5.0
@ -60,71 +74,3 @@ services:
- LDAP_DOMAIN=${LDAP_DOMAIN}
volumes:
- ${DATADIR}/ldap:/container/service/slapd/assets/config/bootstrap/ldif/custom
redis:
container_name: cc-redis
image: redis
command: [
"redis-server",
"--save", "",
"--maxmemory", "2gb",
"--maxmemory-policy", "allkeys-lru"]
php:
container_name: cc-php
build:
context: ./php-fpm
args:
PHP_XDEBUG_INIT: ${PHP_XDEBUG_INIT}
PHP_XDEBUG_MODE: ${PHP_XDEBUG_MODE}
PHP_XDEBUG_CLIENT_PORT: ${PHP_XDEBUG_CLIENT_PORT}
PHP_XDEBUG_CLIENT_HOST: ${PHP_XDEBUG_CLIENT_HOST}
SYMFONY_CLI_VERSION: 4.23.2
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
LDAP_PASSWORD: ${LDAP_ADMIN_PASSWORD}
INFLUXDB_PASSWORD: ${INFLUXDB_PASSWORD}
INFLUXDB_PORT: ${INFLUXDB_PORT}
INFLUXDB_ADMIN_TOKEN: ${INFLUXDB_ADMIN_TOKEN}
INFLUXDB_ORG: ${INFLUXDB_ORG}
INFLUXDB_BUCKET: ${INFLUXDB_BUCKET}
INFLUXDB_SSL: ${INFLUXDB_SSL}
APP_ENVIRONMENT: ${APP_ENVIRONMENT}
environment:
- APP_CLUSTERCOCKPIT_INIT=${APP_CLUSTERCOCKPIT_INIT}
- CLUSTERCOCKPIT_BRANCH=${CLUSTERCOCKPIT_BRANCH}
- APP_JWT_PUB_KEY=${APP_JWT_PUB_KEY}
- APP_JWT_PRIV_KEY=${APP_JWT_PRIV_KEY}
volumes:
- ${DATADIR}/symfony:/var/www/symfony
- ${DATADIR}/job-archive:/var/lib/job-archive
depends_on:
- db
- redis
- influxdb
nginx:
container_name: cc-nginx
build:
context: ./nginx
ports:
- "127.0.0.1:${NGINX_PORT}:80"
depends_on:
- php
environment:
- NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx/conf.d
- NGINX_ENVSUBST_TEMPLATE_DIR=/etc/nginx/templates
- NGINX_ENVSUBST_TEMPLATE_SUFFIX=.template
volumes:
- ${DATADIR}/symfony:/var/www/symfony
phpmyadmin:
container_name: cc-phpmyadmin
image: phpmyadmin
environment:
- PMA_HOST=cc-db
- PMA_USER=root
- PMA_PASSWORD=${MYSQL_ROOT_PASSWORD}
ports:
- "127.0.0.1:${PHPMYADMIN_PORT}:80"

View File

@ -1,8 +0,0 @@
FROM nginx:mainline-alpine
RUN mkdir -p /etc/nginx/templates
COPY templates/* /etc/nginx/templates/
COPY nginx.conf /etc/nginx/
CMD ["nginx"]
EXPOSE 80

View File

@ -1,48 +0,0 @@
user nginx;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_body_buffer_size 256k;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 2 1k;
client_body_temp_path /tmp 1 2;
client_body_in_file_only off;
keepalive_timeout 90;
send_timeout 120;
reset_timedout_connection on;
open_file_cache max=2000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
access_log off;
error_log off;
gzip on;
gzip_comp_level 9;
gzip_min_length 200;
gzip_types text/plain text/html text/css application/json;
include /etc/nginx/conf.d/*.conf;
}
daemon off;

View File

@ -1,23 +0,0 @@
server {
server_name localhost;
root /var/www/symfony/public;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass php-upstream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param HTTPS off;
fastcgi_read_timeout 300;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ \.php$ {
return 404;
}
}

View File

@ -1,3 +0,0 @@
upstream php-upstream {
server php:9001;
}

View File

@ -1,99 +0,0 @@
FROM php:8.0-fpm
RUN apt-get update && apt-get install -y \
$PHPIZE_DEPS \
git \
wget \
zip \
gettext \
bash \
libldb-dev \
libldap-2.4-2 \
libldap-common \
libldap2-dev \
npm \
nodejs
RUN apt-get clean
RUN npm install --global yarn
RUN docker-php-ext-install ldap \
mysqli \
pdo_mysql \
opcache
# Enable php8-xdebug if $PHP_XDEBUG_INIT is true
ARG PHP_XDEBUG_INIT="false"
ARG PHP_XDEBUG_MODE=off
ARG PHP_XDEBUG_CLIENT_PORT=5902
ARG PHP_XDEBUG_CLIENT_HOST=host.docker.internal
COPY xdebug.ini /etc/php8/conf.d/xdebug.ini.template
COPY error_reporting.ini /usr/local/etc/php/conf.d/error_reporting.ini
RUN if [[ "$PHP_XDEBUG_INIT" == "true" ]]; then \
pecl install xdebug-3.0.4; \
docker-php-ext-enable xdebug; \
export PHP_XDEBUG_MODE=$PHP_XDEBUG_MODE; \
export PHP_XDEBUG_CLIENT_PORT=$PHP_XDEBUG_CLIENT_PORT; \
export PHP_XDEBUG_CLIENT_HOST=$PHP_XDEBUG_CLIENT_HOST; \
envsubst < /etc/php8/conf.d/xdebug.ini.template > /etc/php8/conf.d/xdebug.ini; \
cp /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini.back; \
cp /etc/php8/conf.d/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
rm -f /etc/php8/conf.d/xdebug.ini.template; \
fi
RUN curl -sS https://getcomposer.org/installer | tee composer-setup.php \
&& php composer-setup.php && rm composer-setup.php* \
&& chmod +x composer.phar && mv composer.phar /usr/bin/composer
ARG SYMFONY_CLI_VERSION
RUN wget https://github.com/symfony/cli/releases/download/v$SYMFONY_CLI_VERSION/symfony_linux_amd64.gz \
&& gzip -d symfony_linux_amd64.gz \
&& mv symfony_linux_amd64 symfony \
&& chmod +x symfony \
&& mv symfony /usr/local/bin/
RUN mkdir -p /var/lib/job-archive
RUN mkdir -p /var/www/symfony
VOLUME /var/www/symfony /var/lib/job-archive
COPY php.ini /usr/local/etc/php/
COPY symfony.ini /usr/local/etc/php/conf.d/
COPY symfony.ini /usr/local/etc/php/cli/conf.d/
COPY symfony.pool.conf /usr/local/etc/php/php-fpm.d/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ARG APP_ENVIRONMENT
ENV APP_ENV=${APP_ENVIRONMENT}
ENV APP_SECRET=${APP_SECRET}
ENV APP_JWT_PUB_KEY="${APP_JWT_PUB_KEY}"
ENV APP_JWT_PRIV_KEY="${APP_JWT_PRIV_KEY}"
ENV APP_DEBUG=1
ENV REDIS_URL=redis://cc-redis
ENV LDAP_URL=ldap://cc-ldap
ARG INFLUXDB_PORT
ARG INFLUXDB_PASSWORD
ARG INFLUXDB_ADMIN_TOKEN
ARG INFLUXDB_ORG
ARG INFLUXDB_BUCKET
ARG INFLUXDB_SSL
ENV INFLUXDB_URL=http://cc-influxdb:${INFLUXDB_PORT}
ENV INFLUXDB_SSL=${INFLUXDB_SSL}
ENV INFLUXDB_TOKEN=${INFLUXDB_ADMIN_TOKEN}
ENV INFLUXDB_ORG=${INFLUXDB_ORG}
ENV INFLUXDB_BUCKET=${INFLUXDB_BUCKET}
ARG LDAP_PASSWORD
ENV LDAP_PW=${LDAP_PASSWORD}
ARG MYSQL_USER
ARG MYSQL_PASSWORD
ARG MYSQL_DATABASE
ENV DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@cc-db:3306/${MYSQL_DATABASE}
ENV CORS_ALLOW_ORIGIN=^https?://(localhost|127\\.0\\.0\\.1)(:[0-9]+)?$
WORKDIR /var/www/symfony
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm", "-F", "-y/usr/local/etc/php/php-fpm.d/symfony.pool.conf"]
EXPOSE 9001

View File

@ -1,24 +0,0 @@
#!/usr/bin/env bash
if [ "$APP_CLUSTERCOCKPIT_INIT" = true ]; then
rm -rf /var/www/symfony/* /var/www/symfony/.??*
git clone -b $CLUSTERCOCKPIT_BRANCH https://github.com/ClusterCockpit/ClusterCockpit .
if [ "$APP_ENV" = dev ]; then
composer install --no-progress --optimize-autoloader
yarn install
yarn encore dev
else
composer install --no-dev --no-progress --optimize-autoloader
yarn install
yarn encore production
fi
ln -s /var/lib/job-archive var/job-archive
chown -R www-data:www-data /var/www/symfony/* /var/www/symfony/.??*
fi
# Reports php environment on container startup
php bin/console about
exec "$@"

View File

@ -1 +0,0 @@
error_reporting=E_ALL

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
date.timezone = UTC

View File

@ -1,100 +0,0 @@
; Start a new pool named 'symfony'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('symfony' here)
[symfony]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 0.0.0.0:9001
; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 20
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 2
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 1
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3
;---------------------
; Make specific Docker environment variables available to PHP
env[APP_ENV] = $APP_ENV
env[APP_SECRET] = $APP_SECRET
env[APP_JWT_PUB_KEY] = $APP_JWT_PUB_KEY
env[APP_JWT_PRIV_KEY] = $APP_JWT_PRIV_KEY
env[APP_DEBUG] = $APP_DEBUG
env[INFLUXDB_URL] = $INFLUXDB_URL
env[INFLUXDB_TOKEN] = $INFLUXDB_TOKEN
env[INFLUXDB_ORG] = $INFLUXDB_ORG
env[INFLUXDB_BUCKET] = $INFLUXDB_BUCKET
env[INFLUXDB_SSL] = $INFLUXDB_SSL
env[DATABASE_URL] = $DATABASE_URL
env[REDIS_URL] = $REDIS_URL
env[LDAP_URL] = $LDAP_URL
env[LDAP_PW] = $LDAP_PW
env[CORS_ALLOW_ORIGIN] = $CORS_ALLOW_ORIGIN
; Catch worker output
catch_workers_output = yes
; Increase PHP memory limit (Default: 128M)
; Note: Required for loading large jobs from InfluxDB (>16 Nodes && >12h Duration)
php_admin_value[memory_limit] = 1024M

View File

@ -1,7 +0,0 @@
zend_extension=xdebug.so
[Xdebug]
xdebug.mode=${PHP_XDEBUG_MODE}
xdebug.client_port=${PHP_XDEBUG_CLIENT_PORT}
xdebug.client_host=${PHP_XDEBUG_CLIENT_HOST}
xdebug.start_with_request=yes

20
startDev.sh Normal file
View File

@ -0,0 +1,20 @@
#!/bin/sh
# mkdir ./var
# cd ./var
#
# wget https://hpc-mover.rrze.uni-erlangen.de/HPC-Data/0x7b58aefb/eig7ahyo6fo2bais0ephuf2aitohv1ai/job-archive.tar.xz
# tar xJf job-archive.tar.xz
# rm ./job-archive.tar.xz
#
# touch ./job.db
# cd ../frontend
# yarn install
# yarn build
#
# cd ..
# go get
# go build
#
# ./cc-backend --init-db --add-user demo:admin:AdminDev --no-server
# ./cc-backend