From 18d97850e90d5fc32456232f76a738fc06072bfc Mon Sep 17 00:00:00 2001 From: Mayo Date: Mon, 16 Mar 2020 15:00:15 +0800 Subject: [PATCH] update stacks --- docker-compose.apollo.yml | 0 ....example.yml => docker-compose.default.yml | 0 docker-compose.kafka.yml | 43 +++++ docker-compose.kong.yml | 109 +++++++++++++ docker-compose.v2.yml | 149 ++++++++++++++++++ env.example | 41 +++++ haproxy/Dockerfile | 7 +- 7 files changed, 343 insertions(+), 6 deletions(-) create mode 100644 docker-compose.apollo.yml rename docker-compose.example.yml => docker-compose.default.yml (100%) create mode 100644 docker-compose.kafka.yml create mode 100644 docker-compose.kong.yml create mode 100644 docker-compose.v2.yml create mode 100644 env.example diff --git a/docker-compose.apollo.yml b/docker-compose.apollo.yml new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.example.yml b/docker-compose.default.yml similarity index 100% rename from docker-compose.example.yml rename to docker-compose.default.yml diff --git a/docker-compose.kafka.yml b/docker-compose.kafka.yml new file mode 100644 index 0000000..7bf5380 --- /dev/null +++ b/docker-compose.kafka.yml @@ -0,0 +1,43 @@ +version: "3" + +networks: + kafka-net: + driver: bridge + +services: + + kafka-zookeeper: + image: wurstmeister/zookeeper + volumes: + - ${DATA_PATH}/kafka-zk:/data + networks: + - kafka-net + # ports: + # - "2181:2181" + + kafka: + image: wurstmeister/kafka + ports: + - "9092:9092" + networks: + - kafka-net + links: + - kafka-zookeeper + environment: + # KAFKA_ADVERTISED_HOST_NAME: 192.168.5.139 + KAFKA_ZOOKEEPER_CONNECT: kafka-zookeeper:2181 + volumes: + - ${LOG_PATH}/kafka:/kafka + - /var/run/docker.sock:/var/run/docker.sock + + + kafka-manager: + image: sheepkiller/kafka-manager + ports: + - 9020:9000 + networks: + - kafka-net + links: + - kafka-zookeeper + environment: + ZK_HOSTS: kafka-zookeeper:2181 \ No newline at end of file diff --git a/docker-compose.kong.yml b/docker-compose.kong.yml new file mode 100644 index 0000000..f9b83f1 --- /dev/null +++ b/docker-compose.kong.yml @@ -0,0 +1,109 @@ +version: "3" + +networks: + kong-net: + driver: bridge + +services: + + ####################################### + # Postgres: The database used by Kong + ####################################### + kong-database: + container_name: kong-database + image: postgres:alpine + volumes: + - ${DATA_PATH}/kong-postgres:/var/lib/postgresql/data + restart: always + networks: + - kong-net + environment: + POSTGRES_USER: kong + POSTGRES_DB: kong + # ports: + # - "5432:5432" + healthcheck: + test: ["CMD", "pg_isready", "-U", "kong"] + interval: 5s + timeout: 5s + retries: 5 + + ####################################### + # Kong database migration + ####################################### + kong-migration: + container_name: kong-migration + image: kong:latest + command: "kong migrations bootstrap" + networks: + - kong-net + restart: on-failure + environment: + KONG_PG_HOST: kong-database + links: + - kong-database + depends_on: + - kong-database + + ####################################### + # Kong: The API Gateway + ####################################### + kong: + container_name: kong + image: kong:latest + restart: always + networks: + - kong-net + environment: + KONG_PG_HOST: kong-database + KONG_PROXY_LISTEN: 0.0.0.0:8000 + KONG_PROXY_LISTEN_SSL: 0.0.0.0:8443 + KONG_ADMIN_LISTEN: 0.0.0.0:8001 + depends_on: + - kong-migration + - kong-database + healthcheck: + test: ["CMD", "curl", "-f", "http://kong:8001"] + interval: 5s + timeout: 2s + retries: 15 + ports: + # - "8001:8001" + - "8000:8000" + - "8443:8443" + + ####################################### + # Konga database prepare + ####################################### + konga-prepare: + container_name: konga-prepare + image: pantsel/konga:next + command: "-c prepare -a postgres -u postgresql://kong@kong-database:5432/konga_db" + networks: + - kong-net + restart: on-failure + links: + - kong-database + depends_on: + - kong-database + + ####################################### + # Konga: Kong GUI + ####################################### + konga: + container_name: konga + image: pantsel/konga:latest + restart: always + networks: + - kong-net + environment: + DB_ADAPTER: postgres + DB_HOST: kong-database + DB_USER: kong + TOKEN_SECRET: km1GUr4RkcQD7DewhJPNXrCuZwcKmqjb + DB_DATABASE: konga_db + NODE_ENV: production + depends_on: + - kong-database + ports: + - "1337:1337" \ No newline at end of file diff --git a/docker-compose.v2.yml b/docker-compose.v2.yml new file mode 100644 index 0000000..94ab0a0 --- /dev/null +++ b/docker-compose.v2.yml @@ -0,0 +1,149 @@ +version: "3" +services: + + haproxy: + container_name: haproxy + image: haproxy:alpine + volumes: + - ${LOG_PATH}/haproxy:/var/log/haproxy + - ./haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg + ports: + - "80:80" + - "443:443" + networks: + - frontend + - backend + restart: always + + openresty: + container_name: openresty + build: + context: ./openresty + args: + - CHINA_MIRROR=${CHINA_MIRROR} + - DEFAULT_TIMEZONE=${DEFAULT_TIMEZONE} + volumes: + - ${APP_PATH}:/opt/app + - ${LOG_PATH}/openresty:/var/log/openresty + - ./openresty/conf/nginx.conf:/etc/nginx/conf.d/conf/nginx.conf + - ./openresty/conf/upstream.conf:/usr/local/openresty/nginx/conf/upstream.conf + - ./openresty/conf/snippets:/usr/local/openresty/nginx/conf/snippets + - ./openresty/sites:/usr/local/openresty/nginx/conf/sites + ports: + - "80:80" + - "443:443" + networks: + - frontend + - backend + restart: always + + php-fpm: + container_name: php-fpm + build: + context: ./php-fpm + args: + - CHINA_MIRROR=${CHINA_MIRROR} + - DEFAULT_TIMEZONE=${DEFAULT_TIMEZONE} + - PHP_EXT_OPCACHE=${PHP_FPM_ENABLE_OPCACHE} + - PHP_EXT_XDEBUG=${PHP_FPM_ENABLE_XDEBUG} + - PHP_EXT_IMAGICK=${PHP_EXT_IMAGICK} + - PHP_EXT_GD=${PHP_EXT_GD} + - PHP_EXT_REDIS=${PHP_EXT_REDIS} + - PHP_EXT_MCRYPT=${PHP_EXT_MCRYPT} + volumes: + - ${APP_PATH}:/opt/app + - ${LOG_PATH}/php-fpm:/var/log/php-fpm + - ./php-fpm/php.ini:/usr/local/etc/php/php.ini + - ./php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf + - ./php-fpm/www.conf:/usr/local/etc/php-fpm.d/www.conf + - ./php-fpm/opcache.ini:/usr/local/etc/php/conf.d/opcache.ini + - ./php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini + networks: + - backend + restart: always + + mariadb: + container_name: mariadb + build: + context: ./mariadb + args: + - CHINA_MIRROR=${CHINA_MIRROR} + - DEFAULT_TIMEZONE=${DEFAULT_TIMEZONE} + volumes: + - ${DATA_PATH}/mariadb:/var/lib/mysql + # - ./mysql/my.cnf:/etc/mysql/my.cnf + # - ${LOG_PATH}/mariadb:/var/log/mysql + environment: + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + # - MYSQL_ALLOW_EMPTY_PASSWORD=true + # ports: + # - "3306:3306" + networks: + - backend + restart: always + + postgres: + container_name: postgres + build: + context: ./postgres + args: + - CHINA_MIRROR=${CHINA_MIRROR} + - DEFAULT_TIMEZONE=${DEFAULT_TIMEZONE} + volumes: + - ${DATA_PATH}/postgres:/var/lib/postgresql/data + # - ${LOG_PATH}/postgres:/var/lib/postgresql/data/log + environment: + - POSTGRES_USER=root + - POSTGRES_PASSWORD=${POSTGRESQL_ROOT_PASSWORD} + ports: + - "5432:5432" + networks: + - backend + restart: always + + redis: + container_name: redis + build: + context: ./redis + args: + - CHINA_MIRROR=${CHINA_MIRROR} + - DEFAULT_TIMEZONE=${DEFAULT_TIMEZONE} + volumes: + - ${DATA_PATH}/redis:/data + - ./redis/redis.conf:/usr/local/etc/redis/redis.conf + # ports: + # - "6379:6379" + networks: + - backend + restart: always + + mongodb: + image: mongo:latest + restart: always + ports: + - "27017:27017" + volumes: + - ${DATA_PATH}/mongodb:/data/db + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD} + + portainer: + container_name: portainer + build: + context: ./portainer + args: + - CHINA_MIRROR=${CHINA_MIRROR} + - DEFAULT_TIMEZONE=${DEFAULT_TIMEZONE} + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ${DATA_PATH}/portainer:/data + ports: + - "9000:9000" + networks: + - frontend + restart: always + +networks: + frontend: + backend: \ No newline at end of file diff --git a/env.example b/env.example new file mode 100644 index 0000000..cbdf1cd --- /dev/null +++ b/env.example @@ -0,0 +1,41 @@ +# Local dir settings +APP_PATH=/opt/app +DATA_PATH=/var/data +LOG_PATH=/var/log/runtime + +### Container dir settings +# CONTAINER_APP_PATH=/opt/app +# CONTAINER_DATA_PATH=/var/data +# CONTAINER_LOG_PATH=/var/log/runtime + +# passwd settings +MYSQL_ROOT_PASSWORD= +POSTGRESQL_ROOT_PASSWORD= +MONGO_ROOT_PASSWORD= + +RABBITMQ_PASSWORD= + +# China mirror setting +CHINA_MIRROR=false + +# Timezone setting +DEFAULT_TIMEZONE=UTC +# DEFAULT_TIMEZONE=Asia/Shanghai + +# PHP options +# - OPCache +WORKSPACE_ENABLE_OPCACHE=false +CRON_ENABLE_OPCACHE=false +PHP_FPM_ENABLE_OPCACHE=false +# - XDebug +WORKSPACE_ENABLE_XDEBUG=false +CRON_ENABLE_XDEBUG=false +PHP_FPM_ENABLE_XDEBUG=false +# - Imagick +PHP_EXT_IMAGICK=false +# - GD +PHP_EXT_GD=false +# - redis +PHP_EXT_REDIS=false +# - mcrypt +PHP_EXT_MCRYPT=false \ No newline at end of file diff --git a/haproxy/Dockerfile b/haproxy/Dockerfile index e102462..9ac7a91 100644 --- a/haproxy/Dockerfile +++ b/haproxy/Dockerfile @@ -1,6 +1 @@ -FROM haproxy:alpine - -# Set Timezone -ARG DEFAULT_TIMEZONE=UTC -RUN apk add --no-cache tzdata -ENV TZ $DEFAULT_TIMEZONE \ No newline at end of file +FROM haproxy:alpine \ No newline at end of file