Add: env variables for services

This commit is contained in:
Stan Yakubenko (HP) 2020-11-19 20:48:41 +05:00
parent ae369aa1dd
commit 1dc7eb490a
9 changed files with 344 additions and 59 deletions

View File

@ -1,3 +1,19 @@
APP_HOME=test_app
USER=stan
# all container will be appended with this
APP_NAME=dev_station
# default user/password pair for all services
USER=user
EMAIL=some@some.com
PASSWORD=password
# ports config
PG_ADMIN_PORT=1080
NGINX_PORT=8080
PG_PORT=5432
RABBIT_PORT=5672
RABBIT_ADMIN_PORT=15672
MYSQL_PORT=3306
MYSQL_LEGACY_PORT=33306
XDEBUG_HOST=172.17.0.1
XDEBUG_PORT=9001
XDEBUG_IDE=VSCODE
#webroot dir
WEB_ROOT=/var/www/public

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.vscode/
.env
docker-compose.yml

94
docker-compose.dist.yml Normal file
View File

@ -0,0 +1,94 @@
version: '3'
services:
nginx:
image: nginx:alpine
container_name: nginx_${APP_NAME}
restart: 'no'
depends_on:
- phpfpm
ports:
- ${NGINX_PORT}:80
volumes:
- .:/var/www
- ./docker/nginx/default:/etc/nginx/conf.d/default.conf
phpfpm:
build: ./docker/php-fpm/
container_name: phpfpm_${APP_NAME}
restart: 'no'
volumes:
- .:/var/www
- ./docker/php-fpm/php.ini:/etc/php/7.4/php.ini
- ./docker/php-fpm/xdebug.ini:/etc/php/7.4/mods-available/xdebug.ini
- ./docker/php-fpm/supervisor.conf:/etc/supervisor/supervisor_nodeamon.conf
- ./docker/imagick/policy.xml:/etc/ImageMagick-6/policy.xml
postgres:
image: postgis/postgis:12-master
container_name: postgis_${APP_NAME}
restart: 'no'
ports:
- ${PG_PORT}:5432
volumes:
- pgsql:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${PASSWORD}
pgadmin:
image: dpage/pgadmin4:latest
restart: 'no'
container_name: pgadmin_${APP_NAME}
ports:
- ${PG_ADMIN_PORT}:80
volumes:
- pgadmin:/var/lib/pgadmin:rw
environment:
PGADMIN_LISTEN_PORT: ${PG_ADMIN_PORT}
PGADMIN_DEFAULT_EMAIL: ${EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PASSWORD}
mysql-legacy:
image: mysql:5.7
restart: 'no'
container_name: mysql_legacy_${APP_NAME}
ports:
- ${MYSQL_LEGACY_PORT}:3306
volumes:
- ./mysql/my.cnf:/etc/alternatives/my.cnf
- ./mysql/mysql.conf.d:/etc/mysql/conf.d/
- mysql_legacy:/var/lib/mysql
environment:
MYSQL_TCP_PORT: ${ZOO_MYSQL_LEGACY_PORT}
MYSQL_ROOT_PASSWORD: ${PASSWORD}
mysql:
image: mysql:latest
container_name: mysql_${APP_NAME}
restart: 'no'
environment:
MYSQL_TCP_PORT: ${MYSQL_PORT}
MYSQL_ROOT_PASSWORD: ${PASSWORD}
ports:
- ${MYSQL_PORT}:3306
volumes:
- mysql:/var/lib/mysql
- ./mysql-latest:/etc/mysql/conf.d
rabbitmq:
image: rabbitmq:3-management
container_name: rabbit_${APP_NAME}
restart: 'no'
ports:
- ${RABBIT_ADMIN_PORT}:15672
- ${RABBIT_PORT}:5672
environment:
RABBITMQ_DEFAULT_USER: ${USER}
RABBITMQ_DEFAULT_PASS: ${PASSWORD}
RABBITMQ_DEFAULT_VHOST: rabbitmq
volumes:
pgsql:
mysql:
mysql_legacy:
pgadmin:

View File

@ -1,53 +0,0 @@
version: '3'
services:
nginx:
image: nginx:alpine
container_name: nginx_${APP_NAME}
restart: 'no'
depends_on:
- phpfpm
ports:
- "8080:80"
volumes:
- .:/var/www
- ./docker/nginx/default:/etc/nginx/conf.d/default.conf
postgres:
image: postgis/postgis:12-master
container_name: postgis_${APP_NAME}
restart: 'no'
ports:
- "5432:5432"
volumes:
- pgsql:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${PASSWORD}
phpfpm:
build: ./docker/php-fpm/
container_name: phpfpm_${APP_NAME}
restart: 'no'
depends_on:
- postgres
volumes:
- .:/var/www
- ./docker/php-fpm/php.ini:/etc/php/7.4/php.ini
- ./docker/php-fpm/xdebug.ini:/etc/php/7.4/mods-available/xdebug.ini
- ./docker/php-fpm/supervisor.conf:/etc/supervisor/supervisor_nodeamon.conf
- ./docker/imagick/policy.xml:/etc/ImageMagick-6/policy.xml
rabbitmq:
image: rabbitmq:3-management
container_name: rabbit_${APP_NAME}
restart: 'no'
ports:
- "15672:15672"
- "5672:5672"
environment:
RABBITMQ_DEFAULT_USER: ${USER}
RABBITMQ_DEFAULT_PASS: ${PASSWORD}
RABBITMQ_DEFAULT_VHOST: rabbitmq
volumes:
pgsql:

View File

@ -0,0 +1,19 @@
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
default_authentication_plugin=mysql_native_password
character-set-client-handshake = false
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET collation_connection = utf8mb4_unicode_ci'
init_connect='SET NAMES utf8mb4'
skip-character-set-client-handshake
slow-query-log = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
long_query_time = 2

102
docker/mysql/my.cnf Normal file
View File

@ -0,0 +1,102 @@
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
#log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
innodb_force_recovery=0
#sql-mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
sql_mode = ''
key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
# myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#Bitrix recomendations
table_open_cache = 1024
transaction-isolation = READ-COMMITTED
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql_general.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
innodb_buffer_pool_size=512M
# innodb_additional_mem_pool_size=128M
# innodb_file_io_threads=8
innodb_lock_wait_timeout=50
innodb_log_buffer_size=8M
innodb_flush_log_at_trx_commit=2
#bitrix
innodb_flush_method = O_DIRECT
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

View File

@ -0,0 +1,106 @@
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
#log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
innodb_force_recovery=0
#sql-mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
sql_mode = ''
key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
# myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#Bitrix recomendations
table_open_cache = 1024
transaction-isolation = READ-COMMITTED
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql_general.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
innodb_buffer_pool_size=512M
# innodb_additional_mem_pool_size=128M
# innodb_file_io_threads=8
innodb_lock_wait_timeout=50
innodb_log_buffer_size=8M
innodb_flush_log_at_trx_commit=2
#bitrix
innodb_flush_method = O_DIRECT

View File

@ -4,7 +4,7 @@ server {
listen 80 default_server;
index index.php;
root /var/www/public;
root ${WEB_ROOT};
location / {
try_files $uri /index.php$is_args$args;

View File

@ -8,6 +8,6 @@ xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="/tmp"
xdebug.show_local_vars=1
xdebug.remote_port=9001
xdebug.remote_host=172.17.0.1
xdebug.idekey=VSCODE
xdebug.remote_port=${XDEBUG_PORT}
xdebug.remote_host=${XDEBUG_HOST}
xdebug.idekey=${XDEBUG_IDE}