From 044261b06fe461c5193581c9863531b06cc343df Mon Sep 17 00:00:00 2001 From: Stefan Neuhaus Date: Thu, 25 Jul 2019 12:03:21 +0200 Subject: [PATCH] Implement Gearman Message broker & PHP Extension --- .travis.yml | 2 +- DOCUMENTATION/content/introduction/index.md | 1 + docker-compose.yml | 36 +++++++++++++++ env-example | 50 ++++++++++++++++++++- gearman/Dockerfile | 5 +++ php-fpm/Dockerfile | 24 ++++++++++ php-worker/Dockerfile | 7 +++ workspace/Dockerfile | 12 +++++ 8 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 gearman/Dockerfile diff --git a/.travis.yml b/.travis.yml index 8773aa32..8d92a02b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ env: - PHP_VERSION=NA BUILD_SERVICE="mssql rethinkdb aerospike" - PHP_VERSION=NA BUILD_SERVICE="blackfire minio percona nginx caddy apache2 mysql mariadb postgres postgres-postgis neo4j mongo redis cassandra" - PHP_VERSION=NA BUILD_SERVICE="adminer phpmyadmin pgadmin" - - PHP_VERSION=NA BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq elasticsearch certbot mailhog maildev selenium jenkins proxy proxy2 haproxy" + - PHP_VERSION=NA BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq elasticsearch certbot mailhog maildev selenium jenkins proxy proxy2 haproxy gearman" - PHP_VERSION=NA BUILD_SERVICE="kibana grafana laravel-echo-server" - PHP_VERSION=NA BUILD_SERVICE="ipython-controller manticore" # - PHP_VERSION=NA BUILD_SERVICE="aws" diff --git a/DOCUMENTATION/content/introduction/index.md b/DOCUMENTATION/content/introduction/index.md index 143faa20..48acd748 100644 --- a/DOCUMENTATION/content/introduction/index.md +++ b/DOCUMENTATION/content/introduction/index.md @@ -149,6 +149,7 @@ That's it! enjoy :) - Eclipse Mosquitto - PHP Worker - Laravel Horizon + - Gearman - **Mail Servers:** - Mailu diff --git a/docker-compose.yml b/docker-compose.yml index 6773264b..6712fd46 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -70,6 +70,7 @@ services: - INSTALL_MONGO=${WORKSPACE_INSTALL_MONGO} - INSTALL_AMQP=${WORKSPACE_INSTALL_AMQP} - INSTALL_CASSANDRA=${WORKSPACE_INSTALL_CASSANDRA} + - INSTALL_GEARMAN=${WORKSPACE_INSTALL_GEARMAN} - INSTALL_PHPREDIS=${WORKSPACE_INSTALL_PHPREDIS} - INSTALL_MSSQL=${WORKSPACE_INSTALL_MSSQL} - INSTALL_NODE=${WORKSPACE_INSTALL_NODE} @@ -157,6 +158,7 @@ services: - INSTALL_MONGO=${PHP_FPM_INSTALL_MONGO} - INSTALL_AMQP=${PHP_FPM_INSTALL_AMQP} - INSTALL_CASSANDRA=${PHP_FPM_INSTALL_CASSANDRA} + - INSTALL_GEARMAN=${PHP_FPM_INSTALL_GEARMAN} - INSTALL_MSSQL=${PHP_FPM_INSTALL_MSSQL} - INSTALL_BCMATH=${PHP_FPM_INSTALL_BCMATH} - INSTALL_GMP=${PHP_FPM_INSTALL_GMP} @@ -225,6 +227,7 @@ services: - INSTALL_MYSQL_CLIENT=${PHP_WORKER_INSTALL_MYSQL_CLIENT} - INSTALL_AMQP=${PHP_WORKER_INSTALL_AMQP} - INSTALL_CASSANDRA=${PHP_WORKER_INSTALL_CASSANDRA} + - INSTALL_GEARMAN=${PHP_WORKER_INSTALL_GEARMAN} - INSTALL_GHOSTSCRIPT=${PHP_WORKER_INSTALL_GHOSTSCRIPT} - INSTALL_SWOOLE=${PHP_WORKER_INSTALL_SWOOLE} - INSTALL_TAINT=${PHP_WORKER_INSTALL_TAINT} @@ -622,6 +625,39 @@ services: networks: - backend +### Gearman ############################################ + gearman: + build: ./gearman + ports: + - "${GEARMAN_PORT}:4730" + privileged: true + environment: + - GEARMAN_VERSION=${GEARMAN_VERSION} + - GEARMAN_VERBOSE=${GEARMAN_VERBOSE} + - GEARMAN_QUEUE_TYPE=${GEARMAN_QUEUE_TYPE} + - GEARMAN_THREADS=${GEARMAN_THREADS} + - GEARMAN_BACKLOG=${GEARMAN_BACKLOG} + - GEARMAN_FILE_DESCRIPTORS=${GEARMAN_FILE_DESCRIPTORS} + - GEARMAN_JOB_RETRIES=${GEARMAN_JOB_RETRIES} + - GEARMAN_ROUND_ROBIN=${GEARMAN_ROUND_ROBIN} + - GEARMAN_WORKER_WAKEUP=${GEARMAN_WORKER_WAKEUP} + - GEARMAN_KEEPALIVE=${GEARMAN_KEEPALIVE} + - GEARMAN_KEEPALIVE_IDLE=${GEARMAN_KEEPALIVE_IDLE} + - GEARMAN_KEEPALIVE_INTERVAL=${GEARMAN_KEEPALIVE_INTERVAL} + - GEARMAN_KEEPALIVE_COUNT=${GEARMAN_KEEPALIVE_COUNT} + - GEARMAN_MYSQL_HOST=${GEARMAN_MYSQL_HOST} + - GEARMAN_MYSQL_PORT=${GEARMAN_MYSQL_PORT} + - GEARMAN_MYSQL_USER=${GEARMAN_MYSQL_USER} + - GEARMAN_MYSQL_PASSWORD=${GEARMAN_MYSQL_PASSWORD} + - GEARMAN_MYSQL_PASSWORD_FILE=${GEARMAN_MYSQL_PASSWORD_FILE} + - GEARMAN_MYSQL_DB=${GEARMAN_MYSQL_DB} + - GEARMAN_MYSQL_TABLE=${GEARMAN_MYSQL_TABLE} + hostname: laradock-gearman + depends_on: + - php-fpm + networks: + - backend + ### Beanstalkd Console ################################### beanstalkd-console: build: ./beanstalkd-console diff --git a/env-example b/env-example index a4793a7c..d8749d17 100644 --- a/env-example +++ b/env-example @@ -107,6 +107,7 @@ WORKSPACE_INSTALL_IMAP=false WORKSPACE_INSTALL_MONGO=false WORKSPACE_INSTALL_AMQP=false WORKSPACE_INSTALL_CASSANDRA=false +WORKSPACE_INSTALL_GEARMAN=false WORKSPACE_INSTALL_MSSQL=false WORKSPACE_INSTALL_DRUSH=false WORKSPACE_DRUSH_VERSION=8.1.17 @@ -163,6 +164,7 @@ PHP_FPM_INSTALL_IMAP=false PHP_FPM_INSTALL_MONGO=false PHP_FPM_INSTALL_AMQP=false PHP_FPM_INSTALL_CASSANDRA=false +PHP_FPM_INSTALL_GEARMAN=false PHP_FPM_INSTALL_MSSQL=false PHP_FPM_INSTALL_SSH2=false PHP_FPM_INSTALL_SOAP=false @@ -208,6 +210,7 @@ PHP_WORKER_INSTALL_TAINT=false PHP_WORKER_INSTALL_FFMPEG=false PHP_WORKER_INSTALL_GMP=false PHP_WORKER_INSTALL_CASSANDRA=false +PHP_WORKER_INSTALL_GEARMAN=false PHP_WORKER_PUID=1000 PHP_WORKER_PGID=1000 @@ -766,4 +769,49 @@ CASSANDRA_ENABLE_RPC=true # Datacenter name for the cluster. Ignored in SimpleSnitch endpoint snitch. Default: dc1. CASSANDRA_DATACENTER=dc1 # Rack name for the cluster. Ignored in SimpleSnitch endpoint snitch. Default: rack1. -CASSANDRA_RACK=rack1 \ No newline at end of file +CASSANDRA_RACK=rack1 + +### GEARMAN ################################################## + +# Gearman version to use. See available tags at https://hub.docker.com/r/artefactual/gearmand +GEARMAN_VERSION=latest +# Port to use (Default: 6379) +GEARMAN_PORT=6379 +# Logging Level (Default: INFO) +GEARMAN_VERBOSE=INFO +# Persistent queue type to use (Default: builtin) +GEARMAN_QUEUE_TYPE=builtin +# Number of I/O threads to use (Default: 4) +GEARMAN_THREADS=4 +# Number of backlog connections for listen (Default: 32) +GEARMAN_BACKLOG=32 +# Number of file descriptors to allow for the process (Default is max allowed for user) +GEARMAN_FILE_DESCRIPTORS= +# Number of attempts to run the job before the job server removes it. (Default: no limit = 0) +GEARMAN_JOB_RETRIES=0 +# Assign work in round-robin order per worker connection (Default: 0) +GEARMAN_ROUND_ROBIN=0 +# Number of workers to wakeup for each job received (Default: 0) +GEARMAN_WORKER_WAKEUP=0 +# Enable keepalive on sockets (Default: 0) +GEARMAN_KEEPALIVE=0 +# The duration between two keepalive transmissions in idle condition (Default: 30) +GEARMAN_KEEPALIVE_IDLE=30 +# The duration between two successive keepalive retransmissions, if acknowledgement to the previous keepalive transmission is not received (Default: 10) +GEARMAN_KEEPALIVE_INTERVAL=10 +# The number of retransmissions to be carried out before declaring that remote end is not available (Default: 5) +GEARMAN_KEEPALIVE_COUNT=5 +# Mysql server host (Default: localhost) +GEARMAN_MYSQL_HOST=localhost +# Mysql server port (Default: 3306) +GEARMAN_MYSQL_PORT=3306 +# Mysql server user (Default: root) +GEARMAN_MYSQL_USER=root +# Mysql password +GEARMAN_MYSQL_PASSWORD= +# Path to file with mysql password(Docker secrets) +GEARMAN_MYSQL_PASSWORD_FILE= +# Database to use by Gearman (Default: Gearmand) +GEARMAN_MYSQL_DB=Gearmand +# Table to use by Gearman (Default: gearman_queue) +GEARMAN_MYSQL_TABLE=gearman_queue \ No newline at end of file diff --git a/gearman/Dockerfile b/gearman/Dockerfile new file mode 100644 index 00000000..79a0e75b --- /dev/null +++ b/gearman/Dockerfile @@ -0,0 +1,5 @@ +ARG GEARMAN_VERSION=latest +FROM artefactual/gearmand:${GEARMAN_VERSION} + +LABEL maintainer="Stefan Neuhaus " + diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index a25e5f42..54207db7 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -306,6 +306,30 @@ RUN if [ ${INSTALL_AMQP} = true ]; then \ docker-php-ext-install sockets \ ;fi +########################################################################### +# GEARMAN: +########################################################################### + +ARG INSTALL_GEARMAN=false + +RUN if [ ${INSTALL_GEARMAN} = true ]; then \ + apt-get update && \ + apt-get -y install libgearman-dev && \ + cd /tmp && \ + curl -L https://github.com/wcgallego/pecl-gearman/archive/gearman-2.0.5.zip -O && \ + unzip gearman-2.0.5.zip && \ + mv pecl-gearman-gearman-2.0.5 pecl-gearman && \ + cd /tmp/pecl-gearman && \ + phpize && \ + ./configure && \ + make -j$(nproc) && \ + make install && \ + cd / && \ + rm /tmp/gearman-2.0.5.zip && \ + rm -r /tmp/pecl-gearman && \ + docker-php-ext-enable gearman \ +;fi + ########################################################################### # pcntl ########################################################################### diff --git a/php-worker/Dockerfile b/php-worker/Dockerfile index b8d482d2..fdd527cd 100644 --- a/php-worker/Dockerfile +++ b/php-worker/Dockerfile @@ -85,6 +85,13 @@ RUN if [ ${INSTALL_AMQP} = true ]; then \ docker-php-ext-install sockets \ ;fi +# Install Gearman: +ARG INSTALL_GEARMAN=false + +RUN if [ ${INSTALL_GEARMAN} = true ]; then \ + docker-php-ext-install gearman \ +;fi + # Install Cassandra drivers: ARG INSTALL_CASSANDRA=false RUN if [ ${INSTALL_CASSANDRA} = true ]; then \ diff --git a/workspace/Dockerfile b/workspace/Dockerfile index cbbeb2e9..06567f2c 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -437,6 +437,18 @@ RUN if [ ${INSTALL_CASSANDRA} = true ]; then \ ln -s /etc/php/${LARADOCK_PHP_VERSION}/mods-available/cassandra.ini /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/30-cassandra.ini \ ;fi +########################################################################### +# Gearman: +########################################################################### + +ARG INSTALL_GEARMAN=false + +RUN if [ ${INSTALL_GEARMAN} = true ]; then \ + add-apt-repository -y ppa:ondrej/pkg-gearman && \ + apt-get update && \ + apt-get install php-gearman -y \ +;fi + ########################################################################### # PHP REDIS EXTENSION ###########################################################################