├── .editorconfig ├── LICENSE ├── README.md ├── docker-compose.mysql.yml ├── docker-compose.yml ├── env ├── database.mysql.env ├── database.pgsql.env └── phpcensor.env ├── web ├── Dockerfile ├── README.md ├── config.tmpl.yml ├── entrypoint.sh └── nginx.conf └── worker ├── Dockerfile ├── README.md ├── config.tmpl.yml └── entrypoint.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | end_of_line = lf 9 | indent_style = space 10 | indent_size = 4 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017, PHP Censor. 4 | 5 | Copyright (c) 2017, Boyko Alexey. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PHP Censor docker images 2 | ======================== 3 | 4 | *Web image (php-censor-web)* 5 | 6 | ![Web image stars](https://img.shields.io/docker/stars/phpcensor/php-censor-web.svg) 7 | ![Web image pulls](https://img.shields.io/docker/pulls/phpcensor/php-censor-web.svg) 8 | 9 | *Worker image (php-censor-worker)* 10 | 11 | ![Worker image stars](https://img.shields.io/docker/stars/phpcensor/php-censor-worker.svg) 12 | ![Worker image pulls](https://img.shields.io/docker/pulls/phpcensor/php-censor-worker.svg) 13 | 14 | ## Description 15 | 16 | [Docker containers for PHP Censor](https://hub.docker.com/u/phpcensor/) with installed, configured source code 17 | and dependencies, configurable by environment variables `config.yml`. It has separated into two containers parts: 18 | [php-censor-web](./web/README.md) and [php-censor-worker](./worker/README.md) for better scalability. 19 | 20 | You can use docker-compose file (`docker-compose.yml`) that is described below to run a whole stack. 21 | 22 | ## Docker compose 23 | 24 | ### How to use 25 | 26 | Default way with PostgreSQL database: 27 | 28 | ``` 29 | docker-compose -f docker-compose.yml up -d (--build) 30 | ``` 31 | 32 | Or if you want to use it with MySQL (MariaDB): 33 | 34 | ``` 35 | docker-compose -f docker-compose.mysql.yml up -d (--build) 36 | ``` 37 | 38 | If you want to up more worker just use this command, when the PHP Censor stack is already started (but you can do it on 39 | start): 40 | 41 | ``` 42 | docker-compose scale worker=4 43 | ``` 44 | 45 | ### Requirements 46 | 47 | Used `docker-compose.yml` v2.1, which requires: 48 | 49 | * Docker Engine v1.12+ 50 | * Docker Compose v1.9+ 51 | -------------------------------------------------------------------------------- /docker-compose.mysql.yml: -------------------------------------------------------------------------------- 1 | version: "2.1" 2 | services: 3 | db: 4 | extends: 5 | file: ./docker-compose.yml 6 | service: db 7 | user: root 8 | image: "mariadb" 9 | env_file: 10 | - ./env/database.mysql.env 11 | web: 12 | extends: 13 | file: ./docker-compose.yml 14 | service: web 15 | environment: 16 | - DB_TYPE=mysql 17 | - DB_PORT=3306 18 | worker: 19 | extends: 20 | file: ./docker-compose.yml 21 | service: worker 22 | environment: 23 | - DB_TYPE=mysql 24 | - DB_PORT=3306 25 | queue: 26 | extends: 27 | file: ./docker-compose.yml 28 | service: queue 29 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | services: 3 | web: 4 | build: ./web 5 | #image: "phpcensor/php-censor-web:latest" 6 | ports: 7 | - "80:80" 8 | env_file: 9 | - ./env/phpcensor.env 10 | volumes: 11 | - ./artifacts:/var/www/html/public/artifacts 12 | worker: 13 | build: ./worker 14 | #image: "phpcensor/php-censor-worker:latest" 15 | env_file: 16 | - ./env/phpcensor.env 17 | volumes: 18 | - ./artifacts:/var/www/html/public/artifacts 19 | db: 20 | image: "postgres" 21 | user: postgres 22 | env_file: 23 | - ./env/database.pgsql.env 24 | queue: 25 | image: "schickling/beanstalkd" 26 | networks: 27 | default: 28 | aliases: 29 | - beanstalk 30 | -------------------------------------------------------------------------------- /env/database.mysql.env: -------------------------------------------------------------------------------- 1 | MYSQL_RANDOM_ROOT_PASSWORD=yes 2 | MYSQL_DATABASE=phpcensor 3 | MYSQL_USER=phpcensor 4 | MYSQL_PASSWORD=changethepass 5 | -------------------------------------------------------------------------------- /env/database.pgsql.env: -------------------------------------------------------------------------------- 1 | POSTGRES_DB=phpcensor 2 | POSTGRES_USER=phpcensor 3 | POSTGRES_PASSWORD=changethepass 4 | -------------------------------------------------------------------------------- /env/phpcensor.env: -------------------------------------------------------------------------------- 1 | DB_HOST=db 2 | DB_USER=phpcensor 3 | DB_PASS=changethepass 4 | DB_NAME=phpcensor 5 | BEANSTALK_HOST=beanstalk 6 | BEANSTALK_QUEUE_NAME=phpcensor 7 | DB_TYPE=pgsql 8 | DB_PORT=5432 9 | SITE_URL=http://changeMe.com 10 | GITHUB_TOKEN=changeYouSecretKey 11 | ADMIN_NAME=changeNameAdmin 12 | ADMIN_EMAIL=admin@email.com 13 | ADMIN_PASSWORD=adminPassWord 14 | -------------------------------------------------------------------------------- /web/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.4-fpm-alpine 2 | 3 | MAINTAINER Dmitry Khomutov 4 | 5 | ENV PHPCENSOR_VERSION=master 6 | 7 | WORKDIR /var/www/html 8 | 9 | RUN apk add --no-cache $PHPIZE_DEPS && \ 10 | apk update && \ 11 | apk add git nginx openssh postgresql-dev openldap-dev gettext zlib-dev libzip-dev && \ 12 | pecl install xdebug-2.9.8 && \ 13 | curl -sS https://getcomposer.org/installer | php && \ 14 | mv composer.phar /usr/bin/composer 15 | 16 | RUN docker-php-ext-install -j$(grep -c ^processor /proc/cpuinfo) pdo pdo_mysql pdo_pgsql ldap zip bcmath && \ 17 | docker-php-ext-enable xdebug 18 | 19 | RUN git clone -b $PHPCENSOR_VERSION --single-branch --depth 1 https://github.com/php-censor/php-censor.git . && chmod +x ./bin/console 20 | 21 | RUN composer install 22 | 23 | ADD entrypoint.sh / 24 | ADD config.tmpl.yml / 25 | ADD nginx.conf /etc/nginx/nginx.conf 26 | 27 | ENV ADMIN_NAME=admin 28 | ENV ADMIN_EMAIL=admin@php-censor.local 29 | ENV ADMIN_PASSWORD=admin 30 | ENV DB_HOST=localhost 31 | ENV DB_TYPE=mysql 32 | ENV DB_NAME=phpcensor 33 | ENV DB_USER=phpcensor 34 | ENV DB_PASS=changethepass 35 | ENV SITE_URL=http://phpcensor.localhost 36 | ENV BEANSTALK_HOST=localhost 37 | ENV BEANSTALK_QUEUE_NAME=phpcensor 38 | 39 | EXPOSE 80 40 | 41 | ENTRYPOINT ["/entrypoint.sh"] 42 | -------------------------------------------------------------------------------- /web/README.md: -------------------------------------------------------------------------------- 1 | # PHPCensor web-part 2 | 3 | ## Description 4 | 5 | Web part of PHPCensor with nginx and php-fpm. 6 | 7 | ## How to use 8 | 9 | Sample run command (all needed containers like Beanstald, worker and database are in a network): 10 | 11 | ``` 12 | docker network create phpcensor 13 | docker run -d -p 8080:80 --net=phpcensor -e DB_HOST=db -e DB_USER=phpcensor -e DB_PASS=changeme -e DB_NAME=phpcensor -e SITE_URL=http://phpcensor.local -e BEANSTALK_HOST=beanstalk -e BEANSTALK_QUEUE_NAME=phpcensor phpcensor/php-censor-web 14 | ``` 15 | 16 | Remember, this container is web-part and includes only FPM and Nginx, you should run database, 17 | Beanstalkd and [workers](https://github.com/php-censor/docker-php-censor/tree/master/worker) to build your projects. 18 | 19 | ### Configuration 20 | 21 | There are two ways how to configure PHP Censor: 22 | 23 | * Pass environment variables in container. 24 | * Move your `config.yml` by docker volume in `/var/www/html/app/config.yml`. 25 | 26 | By environment variables you can configure these values: 27 | 28 | ``` 29 | # All values with $ will be substituted by your environment variables 30 | 31 | php-censor: 32 | database: 33 | servers: 34 | read: 35 | - host: $DB_HOST 36 | port: **Will be taken from $DB_HOST** 37 | write: 38 | - host: $DB_HOST 39 | port: **Will be taken from $DB_HOST** 40 | type: $DB_TYPE 41 | name: $DB_NAME 42 | username: $DB_USER 43 | password: $DB_PASS 44 | language: en 45 | per_page: 10 46 | url: '$SITE_URL' 47 | email_settings: 48 | from_address: $SMTP_FROM 49 | smtp_address: $SMTP_HOST 50 | smtp_port: $SMTP_PORT 51 | smtp_username: $SMTP_USER 52 | smtp_password: $SMTP_PASSWORD 53 | from_address: $SMTP_FROM 54 | default_mailto_address: $SMTP_DEFAULTTO 55 | smtp_encryption: $SMTP_ENCRYPT 56 | queue: 57 | host: $BEANSTALK_HOST 58 | name: $BEANSTALK_QUEUE_NAME 59 | lifetime: 600 60 | github: 61 | token: $GITHUB_TOKEN 62 | comments: 63 | commit: false 64 | pull_request: false 65 | build: 66 | remove_builds: true 67 | security: 68 | disable_auth: false 69 | default_user_id: 1 70 | auth_providers: 71 | internal: 72 | type: internal 73 | ldap: 74 | type: ldap 75 | data: 76 | host: $LDAP_HOST 77 | port: $LDAP_PORT 78 | base_dn: $LDAP_BASE_DN 79 | mail_attribute: $LDAP_MAIL_ATTRIBUTE 80 | ``` 81 | 82 | And specify admin user by these variables: 83 | 84 | * `ADMIN_NAME` (**default: admin**) 85 | * `ADMIN_PASSWORD` (**default: admin**) 86 | * `ADMIN_EMAIL` (**default: admin@php-censor.local**) 87 | 88 | Default values: 89 | 90 | In progress 91 | -------------------------------------------------------------------------------- /web/config.tmpl.yml: -------------------------------------------------------------------------------- 1 | php-censor: 2 | database: 3 | servers: 4 | read: 5 | - host: $DB_HOST 6 | port: $DB_PORT 7 | write: 8 | - host: $DB_HOST 9 | port: $DB_PORT 10 | type: $DB_TYPE 11 | name: $DB_NAME 12 | username: $DB_USER 13 | password: $DB_PASS 14 | language: en 15 | per_page: 10 16 | url: '$SITE_URL' 17 | email_settings: 18 | from_address: $SMTP_FROM 19 | smtp_address: $SMTP_HOST 20 | smtp_port: $SMTP_PORT 21 | smtp_username: $SMTP_USER 22 | smtp_password: $SMTP_PASSWORD 23 | default_mailto_address: $SMTP_DEFAULTTO 24 | smtp_encryption: $SMTP_ENCRYPT 25 | queue: 26 | host: $BEANSTALK_HOST 27 | name: $BEANSTALK_QUEUE_NAME 28 | lifetime: 600 29 | github: 30 | token: $GITHUB_TOKEN 31 | comments: 32 | commit: false 33 | pull_request: false 34 | build: 35 | remove_builds: true 36 | security: 37 | disable_auth: false 38 | default_user_id: 1 39 | auth_providers: 40 | internal: 41 | type: internal 42 | ldap: 43 | type: ldap 44 | data: 45 | host: $LDAP_HOST 46 | port: $LDAP_PORT 47 | base_dn: $LDAP_BASE_DN 48 | mail_attribute: $LDAP_MAIL_ATTRIBUTE 49 | -------------------------------------------------------------------------------- /web/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eo pipefail 3 | 4 | # Check external services (db, queue) on ready 5 | wait_for_external_services() { 6 | local BEANSTALK_DEFAULT_PORT="11300" 7 | while ! ( nc -w 2 -v "$DB_HOST" "$DB_PORT" < /dev/null && nc -w 2 -v "$BEANSTALK_HOST" $BEANSTALK_DEFAULT_PORT < /dev/null ) 8 | do 9 | echo "Wait for db and queue" 10 | sleep 2 11 | done 12 | } 13 | 14 | # Process DB args and set it to global 15 | parse_args() { 16 | local NON_PARSED_DB_HOST=$DB_HOST 17 | 18 | export DB_HOST=$(echo "$NON_PARSED_DB_HOST" | awk -F ":" '{ print $1 }') 19 | export DB_PORT=$(echo "$NON_PARSED_DB_HOST" | awk -F ":" '{ if (ENVIRON["DB_PORT"] != "") print ENVIRON["DB_PORT"]; else print $2 }') 20 | 21 | if [ -z "$DB_PORT" ]; then 22 | case "$DB_TYPE" in 23 | pgsql) 24 | export DB_PORT=5432 25 | ;; 26 | mysql) 27 | export DB_PORT=3306 28 | ;; 29 | esac 30 | fi 31 | } 32 | 33 | # Entrypoint 34 | main() { 35 | parse_args 36 | 37 | if [ ! -f ./app/config.yml ]; then 38 | envsubst < /config.tmpl.yml > ./app/config.yml 39 | fi 40 | 41 | wait_for_external_services 42 | 43 | 44 | ./bin/console php-censor:install --config-from-file=yes --admin-name="$ADMIN_NAME" \ 45 | --admin-password="$ADMIN_PASSWORD" --admin-email="$ADMIN_EMAIL" 46 | 47 | nginx 48 | php-fpm 49 | } 50 | 51 | main 52 | -------------------------------------------------------------------------------- /web/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes 4; 3 | 4 | pid /var/run/nginx.pid; 5 | 6 | events { 7 | worker_connections 1024; 8 | } 9 | 10 | http { 11 | include mime.types; 12 | default_type application/octet-stream; 13 | 14 | sendfile on; 15 | 16 | keepalive_timeout 65; 17 | 18 | gzip on; 19 | 20 | server { 21 | listen 80; 22 | server_name localhost; 23 | root /var/www/html/public; 24 | 25 | error_log stderr; 26 | access_log /dev/stdout; 27 | 28 | location / { 29 | try_files $uri @php-censor; 30 | } 31 | 32 | location @php-censor { 33 | fastcgi_pass 127.0.0.1:9000; 34 | fastcgi_index index.php; 35 | fastcgi_buffers 256 4k; 36 | include fastcgi_params; 37 | fastcgi_param SCRIPT_FILENAME $document_root/index.php; 38 | fastcgi_param SCRIPT_NAME index.php; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /worker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.4-alpine 2 | 3 | MAINTAINER Dmitry Khomutov 4 | 5 | ENV PHPCENSOR_VERSION=master 6 | 7 | WORKDIR /var/www/html 8 | 9 | RUN apk add --no-cache $PHPIZE_DEPS && \ 10 | apk update && \ 11 | apk add git openssh postgresql-dev gettext zlib-dev libzip-dev && \ 12 | pecl install xdebug-2.9.8 && \ 13 | curl -sS https://getcomposer.org/installer | php && \ 14 | mv composer.phar /usr/bin/composer 15 | 16 | RUN docker-php-ext-install -j$(grep -c ^processor /proc/cpuinfo) pdo pdo_mysql pdo_pgsql zip bcmath && \ 17 | docker-php-ext-enable xdebug 18 | 19 | RUN git clone -b $PHPCENSOR_VERSION --single-branch --depth 1 https://github.com/php-censor/php-censor.git . && chmod +x ./bin/console 20 | 21 | RUN composer install 22 | 23 | ADD entrypoint.sh / 24 | ADD config.tmpl.yml / 25 | 26 | ENV DB_HOST=localhost 27 | ENV DB_TYPE=mysql 28 | ENV DB_NAME=phpcensor 29 | ENV DB_USER=phpcensor 30 | ENV DB_PASS=changethepass 31 | ENV BEANSTALK_HOST=beanstalk 32 | ENV BEANSTALK_QUEUE_NAME=phpcensor 33 | 34 | ENTRYPOINT ["/entrypoint.sh"] 35 | -------------------------------------------------------------------------------- /worker/README.md: -------------------------------------------------------------------------------- 1 | # PHPCensor worker 2 | 3 | ## Description 4 | 5 | PHPCensor worker. 6 | 7 | ## How to use 8 | 9 | Sample run command (all needed containers like Beanstald, web-part and database are in a network): 10 | 11 | ``` 12 | docker network create phpcensor 13 | docker run -d --net=phpcensor -e DB_HOST=db -e DB_USER=phpcensor -e DB_PASS=changeme -e DB_NAME=phpcensor -e BEANSTALK_HOST=beanstalk -e BEANSTALK_QUEUE_NAME=phpcensor phpcensor/php-censor-worker 14 | ``` 15 | 16 | Remember, this container is worker, you should run database, 17 | Beanstalkd and [web](https://github.com/php-censor/docker-php-censor/tree/master/worker) to build your projects. 18 | 19 | *Also you can install your own dependencies, like php-extensions or composer deps, at start time. See below text for further information.* 20 | 21 | ### Configuration 22 | 23 | There are two ways how to configure PHP Censor: 24 | 25 | * Pass environment variables in container. 26 | * Move your `config.yml` by docker volume in `/var/www/html/app/config.yml`. 27 | 28 | By environment variables you can configure these values: 29 | 30 | ``` 31 | # All values with $ will be substituted by your environment variables 32 | 33 | php-censor: 34 | database: 35 | servers: 36 | read: 37 | - host: $DB_HOST 38 | port: **Will be taken from $DB_HOST** 39 | write: 40 | - host: $DB_HOST 41 | port: **Will be taken from $DB_HOST** 42 | type: $DB_TYPE 43 | name: $DB_NAME 44 | username: $DB_USER 45 | password: $DB_PASS 46 | language: en 47 | per_page: 10 48 | url: '$SITE_URL' 49 | email_settings: 50 | from_address: $SMTP_FROM 51 | smtp_address: $SMTP_HOST 52 | smtp_port: $SMTP_PORT 53 | smtp_username: $SMTP_USER 54 | smtp_password: $SMTP_PASSWORD 55 | from_address: $SMTP_FROM 56 | default_mailto_address: $SMTP_DEFAULTTO 57 | smtp_encryption: $SMTP_ENCRYPT 58 | queue: 59 | host: $BEANSTALK_HOST 60 | name: $BEANSTALK_QUEUE_NAME 61 | lifetime: 600 62 | github: 63 | token: $GITHUB_TOKEN 64 | comments: 65 | commit: false 66 | pull_request: false 67 | build: 68 | remove_builds: true 69 | security: 70 | disable_auth: false 71 | default_user_id: 1 72 | auth_providers: 73 | internal: 74 | type: internal 75 | ldap: 76 | type: ldap 77 | data: 78 | host: $LDAP_HOST 79 | port: $LDAP_PORT 80 | base_dn: $LDAP_BASE_DN 81 | mail_attribute: $LDAP_MAIL_ATTRIBUTE 82 | ``` 83 | 84 | You don't have to specify all parameters in worker. Minimal list of params is: 85 | 86 | * `$DB_HOST` 87 | * `$DB_USER` 88 | * `$DB_PASS` 89 | * `$BEANSTALK_HOST` 90 | * `$BEANSTALK_QUEUE_NAME` 91 | * `$DB_TYPE` 92 | 93 | Default values: 94 | 95 | In progress 96 | 97 | ### Installing dependencies and extensions in container 98 | 99 | You can install your dependencies from script. Just pass it by docker volume to **`/docker-init.d/install.sh`**. You can install composer dependencies (e.g. plugins for PHPCensor) or php-extensions by *`docker-php-ext-install`* script (for further information check [official php docker repo](https://hub.docker.com/_/php/)). 100 | 101 | CLI: 102 | 103 | ``` 104 | docker run -d --net=phpcensor -v $PWD/my_install.sh:/docker-init.d/install.sh -e DB_HOST=db -e DB_USER=phpcensor -e DB_PASS=changeme -e DB_NAME=phpcensor -e BEANSTALK_HOST=beanstalk -e BEANSTALK_QUEUE_NAME=phpcensor phpcensor/php-censor-worker 105 | ``` 106 | 107 | docker-compose: 108 | 109 | ``` 110 | ... 111 | worker: 112 | image: phpcensor/php-censor-worker 113 | volumes: 114 | - $PWD/my_install.sh:/docker-init.d/install.sh 115 | env_file: 116 | - ./env/phpcensor.env 117 | ... 118 | ``` 119 | 120 | #### Example of install.sh 121 | 122 | ``` 123 | docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 124 | docker-php-ext-install -j$(grep -c ^processor /proc/cpuinfo) gd mysqli 125 | composer require php-censor/php-censor-deployer-plugin:^1.0 126 | ``` 127 | -------------------------------------------------------------------------------- /worker/config.tmpl.yml: -------------------------------------------------------------------------------- 1 | php-censor: 2 | database: 3 | servers: 4 | read: 5 | - host: $DB_HOST 6 | port: $DB_PORT 7 | write: 8 | - host: $DB_HOST 9 | port: $DB_PORT 10 | type: $DB_TYPE 11 | name: $DB_NAME 12 | username: $DB_USER 13 | password: $DB_PASS 14 | language: en 15 | per_page: 10 16 | url: '$SITE_URL' 17 | email_settings: 18 | from_address: $SMTP_FROM 19 | smtp_address: $SMTP_HOST 20 | smtp_port: $SMTP_PORT 21 | smtp_username: $SMTP_USER 22 | smtp_password: $SMTP_PASSWORD 23 | default_mailto_address: $SMTP_DEFAULTTO 24 | smtp_encryption: $SMTP_ENCRYPT 25 | queue: 26 | host: $BEANSTALK_HOST 27 | name: $BEANSTALK_QUEUE_NAME 28 | lifetime: 600 29 | github: 30 | token: $GITHUB_TOKEN 31 | comments: 32 | commit: false 33 | pull_request: false 34 | build: 35 | remove_builds: true 36 | security: 37 | disable_auth: false 38 | default_user_id: 1 39 | auth_providers: 40 | internal: 41 | type: internal 42 | ldap: 43 | type: ldap 44 | data: 45 | host: $LDAP_HOST 46 | port: $LDAP_PORT 47 | base_dn: $LDAP_BASE_DN 48 | mail_attribute: $LDAP_MAIL_ATTRIBUTE 49 | -------------------------------------------------------------------------------- /worker/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eo pipefail 3 | 4 | # Check external services (db, queue) on ready 5 | wait_for_external_services() { 6 | local BEANSTALK_DEFAULT_PORT="11300" 7 | 8 | while ! ( nc -w 2 -v "$DB_HOST" "$DB_PORT" < /dev/null && nc -w 2 -v "$BEANSTALK_HOST" $BEANSTALK_DEFAULT_PORT < /dev/null ) 9 | do 10 | echo "Wait for db and queue" 11 | sleep 2 12 | done 13 | } 14 | 15 | # Process DB args and set it to global 16 | parse_args() { 17 | local NON_PARSED_DB_HOST=$DB_HOST 18 | 19 | export DB_HOST=$(echo "$NON_PARSED_DB_HOST" | awk -F ":" '{ print $1 }') 20 | export DB_PORT=$(echo "$NON_PARSED_DB_HOST" | awk -F ":" '{ if (ENVIRON["DB_PORT"] != "") print ENVIRON["DB_PORT"]; else print $2 }') 21 | 22 | if [ -z "$DB_PORT" ]; then 23 | case "$DB_TYPE" in 24 | pgsql) 25 | export DB_PORT=5432 26 | ;; 27 | mysql) 28 | export DB_PORT=3306 29 | ;; 30 | esac 31 | fi 32 | } 33 | 34 | # Entrypoint 35 | main() { 36 | parse_args 37 | 38 | if [ ! -f ./app/config.yml ]; then 39 | envsubst < /config.tmpl.yml > ./app/config.yml 40 | fi 41 | 42 | wait_for_external_services 43 | 44 | if [ -f /docker-init.d/install.sh ]; then 45 | echo "Install your dependencies..." 46 | . /docker-init.d/install.sh 47 | echo "Installing is done." 48 | fi 49 | 50 | ./bin/console php-censor:worker --periodical-work 51 | } 52 | 53 | main 54 | --------------------------------------------------------------------------------