From ea4e8da3080ca03c77ead17c86a4b94572405d2e Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Mon, 3 Sep 2018 18:54:16 +0800 Subject: [PATCH] #43 add docker-compose, mysql, redis --- docker-compose.yml | 58 ++++++++++++++++++++++++++++ mysql/admin/start.sh | 18 +++++++++ mysql/admin/stop.sh | 18 +++++++++ mysql/config/conf.d/docker.cnf | 3 ++ mysql/config/conf.d/mysql.cnf | 22 +++++++++++ mysql/config/my.cnf | 26 +++++++++++++ mysql/config/my.cnf.fallback | 25 ++++++++++++ mysql/config/mysql.cnf | 26 +++++++++++++ mysql/config/mysql.conf.d/mysqld.cnf | 28 ++++++++++++++ mysql/data/.gitignore | 2 + redis/admin/start.sh | 18 +++++++++ redis/admin/stop.sh | 18 +++++++++ redis/data/.gitignore | 3 ++ 13 files changed, 265 insertions(+) create mode 100644 docker-compose.yml create mode 100755 mysql/admin/start.sh create mode 100755 mysql/admin/stop.sh create mode 100644 mysql/config/conf.d/docker.cnf create mode 100644 mysql/config/conf.d/mysql.cnf create mode 100644 mysql/config/my.cnf create mode 100644 mysql/config/my.cnf.fallback create mode 100644 mysql/config/mysql.cnf create mode 100644 mysql/config/mysql.conf.d/mysqld.cnf create mode 100644 mysql/data/.gitignore create mode 100755 redis/admin/start.sh create mode 100755 redis/admin/stop.sh create mode 100644 redis/data/.gitignore diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..6150ce2f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,58 @@ +version: '2' +services: + mysql: + image: "mysql:5.6" + restart: always + environment: + - MYSQL_ROOT_PASSWORD=123456 + - MYSQL_DATABASE=contact-center + - MYSQL_USER=admin + - MYSQL_PASSWORD=admin123456 + ports: + - "3306:3306" + volumes: + - $PWD/mysql/data:/var/lib/mysql + - $PWD/mysql/config:/etc/mysql + + redis: + image: redis:latest + restart: always + command: redis-server --appendonly yes + volumes: + - $PWD/redis/data:/data + ports: + - "6379:6379" + + contact-center: + image: "chatopera/contact-center:develop" + restart: always + ports: + - "8035:8080" + - "8036:8036" + volumes: + - $PWD/contact-center/data:/data + - $PWD/contact-center/logs:/logs + environment: + - JAVA_OPTS=-Xmx12288m -Xms2048m -XX:PermSize=256m -XX:MaxPermSize=1024m -Djava.net.preferIPv4Stack=true + - SERVER_PORT=8035 + - SERVER_LOG_PATH=/logs + - SERVER_LOG_LEVEL=INFO + - WEB_UPLOAD_PATH=/data + - SPRING_FREEMARKER_CACHE=true + - SPRING_DATA_ELASTICSEARCH_PROPERTIES_PATH_DATA=/data + - UK_IM_SERVER_PORT=8036 + - UK_IM_SERVER_HOST=localhost + - UK_IM_SERVER_THREADS=10 + - SPRING_DATASOURCE_TYPE=com.alibaba.druid.pool.DruidDataSource + - SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.jdbc.Driver + - SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/contact-center?useUnicode=true&characterEncoding=UTF-8 + - SPRING_DATASOURCE_USERNAME=root + - SPRING_DATASOURCE_PASSWORD=123456 + - MANAGEMENT_SECURITY_ENABLED=false + - SPRING_REDIS_DATABASE=2 + - SPRING_REDIS_HOST=redis + - SPRING_REDIS_PORT=6379 + - CSKEFU_CALLOUT_WATCH_INTERVAL=60000 + depends_on: + - mysql + - redis \ No newline at end of file diff --git a/mysql/admin/start.sh b/mysql/admin/start.sh new file mode 100755 index 00000000..c9c4717f --- /dev/null +++ b/mysql/admin/start.sh @@ -0,0 +1,18 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +cd $baseDir/../.. +if [ -f docker-compose.yml ]; then + docker-compose up mysql +else + echo "Invalid docker compose." + exit 1 +fi \ No newline at end of file diff --git a/mysql/admin/stop.sh b/mysql/admin/stop.sh new file mode 100755 index 00000000..f7479ed4 --- /dev/null +++ b/mysql/admin/stop.sh @@ -0,0 +1,18 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +cd $baseDir/../.. +if [ -f docker-compose.yml ]; then + docker-compose down mysql +else + echo "Invalid docker compose." + exit 1 +fi \ No newline at end of file diff --git a/mysql/config/conf.d/docker.cnf b/mysql/config/conf.d/docker.cnf new file mode 100644 index 00000000..4f1829d6 --- /dev/null +++ b/mysql/config/conf.d/docker.cnf @@ -0,0 +1,3 @@ +[mysqld] +skip-host-cache +skip-name-resolve diff --git a/mysql/config/conf.d/mysql.cnf b/mysql/config/conf.d/mysql.cnf new file mode 100644 index 00000000..a0784260 --- /dev/null +++ b/mysql/config/conf.d/mysql.cnf @@ -0,0 +1,22 @@ +# Copyright (c) 2015, 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 Client configuration file. +# +# For explanations see +# http://dev.mysql.com/doc/mysql/en/server-system-variables.html + +[mysql] diff --git a/mysql/config/my.cnf b/mysql/config/my.cnf new file mode 100644 index 00000000..6c09f4e8 --- /dev/null +++ b/mysql/config/my.cnf @@ -0,0 +1,26 @@ +# Copyright (c) 2015, 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 + +# * IMPORTANT: Additional settings that can override those from this file! +# The files must end with '.cnf', otherwise they'll be ignored. +# +!includedir /etc/mysql/conf.d/ +!includedir /etc/mysql/mysql.conf.d/ diff --git a/mysql/config/my.cnf.fallback b/mysql/config/my.cnf.fallback new file mode 100644 index 00000000..0fce3f60 --- /dev/null +++ b/mysql/config/my.cnf.fallback @@ -0,0 +1,25 @@ +# Copyright (c) 2015, 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 Community Server configuration file. +# +# For explanations see +# http://dev.mysql.com/doc/mysql/en/server-system-variables.html + +# * IMPORTANT: Additional settings that can override those from this file! +# The files must end with '.cnf', otherwise they'll be ignored. +# +!includedir /etc/mysql/conf.d/ diff --git a/mysql/config/mysql.cnf b/mysql/config/mysql.cnf new file mode 100644 index 00000000..6c09f4e8 --- /dev/null +++ b/mysql/config/mysql.cnf @@ -0,0 +1,26 @@ +# Copyright (c) 2015, 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 + +# * IMPORTANT: Additional settings that can override those from this file! +# The files must end with '.cnf', otherwise they'll be ignored. +# +!includedir /etc/mysql/conf.d/ +!includedir /etc/mysql/mysql.conf.d/ diff --git a/mysql/config/mysql.conf.d/mysqld.cnf b/mysql/config/mysql.conf.d/mysqld.cnf new file mode 100644 index 00000000..4fca976c --- /dev/null +++ b/mysql/config/mysql.conf.d/mysqld.cnf @@ -0,0 +1,28 @@ +# 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 +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 diff --git a/mysql/data/.gitignore b/mysql/data/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/mysql/data/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/redis/admin/start.sh b/redis/admin/start.sh new file mode 100755 index 00000000..7f8754b4 --- /dev/null +++ b/redis/admin/start.sh @@ -0,0 +1,18 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +cd $baseDir/../.. +if [ -f docker-compose.yml ]; then + docker-compose up redis +else + echo "Invalid docker compose." + exit 1 +fi \ No newline at end of file diff --git a/redis/admin/stop.sh b/redis/admin/stop.sh new file mode 100755 index 00000000..e5b4d704 --- /dev/null +++ b/redis/admin/stop.sh @@ -0,0 +1,18 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +cd $baseDir/../.. +if [ -f docker-compose.yml ]; then + docker-compose down redis +else + echo "Invalid docker compose." + exit 1 +fi \ No newline at end of file diff --git a/redis/data/.gitignore b/redis/data/.gitignore new file mode 100644 index 00000000..a5baada1 --- /dev/null +++ b/redis/data/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +