Sign inSign up

lhstack/apollo

By lhstack

•Updated about 4 years ago

基于携程apollo构建的镜像

Image
3

1.0K

lhstack/apollo repository overview

⁠高可用搭建,参考这篇博客

使用docker-compose搭建高可用Apollo配置中心⁠

⁠基于携程开源配置中心Apollo项目构建

⁠环境变量说明

⁠通用环境变量

JVM_XMX: "默认: 256m" 
JVM_XMS: "默认: 256m"
JVM_OPTS: "默认: -XX:MaxMetaspaceSize=128m -XX:MetaspaceSize=128m"
DB_HOST: "数据库host地址"
DB_PORT: "数据库端口,默认3306"
DB_NAME: "configservice数据库名称,如果是configservice,adminservice,则默认对应ApolloConfigDB。如果是portal,则默认对应ApolloPortalDB"
DB_USERNAME: "数据库用户名,默认root"
DB_PASSWORD: "数据库密码,默认123456"
MAX_LIFETIME: "hikari对应的max-lifetime,默认600000"
MAX_POOL_SIZE: "hikari对应maximum-pool-size,默认2"
MIN_IDLE_SIZE: "hikari对应minimum-idle,默认1"
IDLE_TIMEOUT: "hikari对应idle-timeout,默认60000"
CONNECTION_TIMEOUT: "hikari对应connection-timeout,默认10000"
LOGFILE_PATH: "日志文件存储地址,默认/app/app.log"

⁠configservice

EUREKA_SERVER_ENABLE: "默认值: false,如果为true,则启动内嵌eureka,并使用默认方式连接内置eureka,不启用ServerConfig中的eureka.service.url" 

⁠adminservice

EUREKA_SERVER_ENABLE: "默认值: false,如果为true,则使用EUREKA_URLS作为eureka注册中心连接的地址,如果为false,则使用ApolloConfigDB中ServerConfig表中的eureka.service.url作为eureka注册中心连接地址"
EUREKA_URLS: "EUREKA_SERVER_ENABLE如果为true,则使用此参数作为eureka主从中心连接地址"

⁠单机docker-compose一键搭建

⁠启动之后需初始流程

  • 1. 进入携程门户网站,http://localhost:8070/
  • 2. 点击右上角导航菜单: 管理员工具
  • 3. 在弹出菜单中点击: 系统参数
  • 4. key后面的输入框填写: apollo.portal.meta.servers
  • 5. 点击查询,然后将{}替换为以下内容,然后点击更新
    {
        "dev":"http://configservice:8080"
    }
    
  • 6. 等待片刻,然后点击创建应用,就会出现dev环境
  • 7. 如要新增环境,参考携程Apollo官网即可

⁠apollo-mysql

script目录用于存放携程Apollo提供的sql脚本,分别为: apolloconfigdb.sql apolloportaldb.sql 相关版本,根据镜像版本去官方查找即可

⁠docker-compose.yml

version: '3'
services:
  portal:
    image: lhstack/apollo:portal-2.0.0
    container_name: portal
    restart: always
    environment:
      DB_HOST: "apollo-mysql"
      DB_PASSWORD: "654321"
    depends_on:
      mysql:
        condition: service_healthy
      configservice:
        condition: service_healthy
    ports:
    - '8070:8080'
    deploy:
      resources:
        limits:
          memory: "384M"
          cpus: '50m'
    logging:
      options:
        max-file: '2'
        max-size: '32k'
  adminservice:
    image: lhstack/apollo:adminservice-2.0.0
    container_name: adminservice
    restart: always
    ports:
    - '8090:8080'
    environment:
      EUREKA_SERVER_ENABLE: "true"
      EUREKA_URLS: "http://configservice:8080/eureka"
      DB_HOST: "apollo-mysql"
      DB_PASSWORD: "654321"
    depends_on:
      mysql:
        condition: service_healthy
      configservice:
        condition: service_healthy
    deploy:
      resources:
        limits:
          memory: "384M"
          cpus: '50m'
    logging:
      options:
        max-file: '2'
        max-size: '32k'
  configservice:
    image: lhstack/apollo:configservice-2.0.0
    container_name: configservice
    restart: always
    ports:
    - '8080:8080'
    environment:
      EUREKA_SERVER_ENABLE: "true"
      DB_HOST: "apollo-mysql"
      DB_PASSWORD: "654321"
    depends_on:
      mysql:
        condition: service_healthy
    healthcheck:
      test: ["CMD-SHELL","wget --no-cache --spider 'http://localhost:8080/health' || exit 1"]
      timeout: 2s
      interval: 10s
      retries: 5
      start_period: 15s
    deploy:
      resources:
        limits:
          memory: "384M"
          cpus: '50m'
    logging:
      options:
        max-file: '2'
        max-size: '32k'
  mysql:
    image: mysql:5.7.28
    container_name: apollo-mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: "654321"
    healthcheck:
      test: ["CMD","mysqladmin","-uroot","-p$${MYSQL_ROOT_PASSWORD}","ping","-h","localhost"]
      timeout: 2s
      interval: 10s
      retries: 5
      start_period: 5s
    volumes:
    - ./data:/var/lib/mysql
    - ./script:/docker-entrypoint-initdb.d/
    deploy:
      resources:
        limits:
          memory: "256M"
          cpus: "50m"

Tag summary

Content type

Image

Digest

sha256:344f8389b…

Size

119.1 MB

Last updated

about 4 years ago

docker pull lhstack/apollo:configservice-1.9.2