jhipster开发期间的单独服务

时间:2018-10-31 10:59:13

标签: docker networking docker-compose jhipster jhipster-registry

目标

我们想创建一个开发环境,在其中可以在服务器上运行最新版本的注册表,uaa和网关。然后,我们想在本地开发和运行(在docker内部或外部)微服务。然后,应将此微服务配置为连接到另一服务器并与之通信。

测试设置

我现在已经通过jhipster子生成器为我们的网关,uaa和注册表生成了一个docker-compose。然后,我尝试通过gradlew启动我当前正在使用的微服务,通过gradlew dockerBuild进行构建,并启动app.yml。我还尝试将app.yml中的主机名更改为localhost,127.0.0.1和注册表docker容器的IP。

我的结果

  • 如果主机名是jhipster-registry:unknownhostexception。最有可能是因为应用程序是在不同的docker-compose文件中启动的。
  • 如果主机名是localhost或127.0.0.1:http://127.0.0.1:8761/config/application/prod/master连接被拒绝。更改为也许需要更多配置?
  • 如果主机名是注册表docker容器的ip:在终端中的jhipster徽标之后,没有其他输出。但是应用程序永远不会因异常而停止。

文件

docker-compose.yml(注册表,UAA和网关)

version: '2'
services:
    mygateway-app:
        image: mygateway
        environment:
            - SPRING_PROFILES_ACTIVE=prod,swagger
            - EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka
            - SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config
            - SPRING_DATASOURCE_URL=jdbc:mysql://mygateway-mysql:3306/mygateway?useUnicode=true&characterEncoding=utf8&useSSL=false
            - JHIPSTER_SLEEP=30
            - JHIPSTER_REGISTRY_PASSWORD=admin
        ports:
            - 8080:8080
        depends_on:
            - "mygateway-mysql"
            - "myuaa-app"
    mygateway-mysql:
        image: mysql:5.7.20
        environment:
            - MYSQL_USER=root
            - MYSQL_ALLOW_EMPTY_PASSWORD=yes
            - MYSQL_DATABASE=mygateway
        command:             mysqld --lower_case_table_names=1 --skip-ssl
            --character_set_server=utf8mb4 --explicit_defaults_for_timestamp

    myuaa-app:
        image: myuaa
        environment:
            - SPRING_PROFILES_ACTIVE=prod,swagger
            - EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka
            - SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config
            - SPRING_DATASOURCE_URL=jdbc:mysql://myuaa-mysql:3306/myuaa?useUnicode=true&characterEncoding=utf8&useSSL=false
            - JHIPSTER_SLEEP=30
            - JHIPSTER_REGISTRY_PASSWORD=admin
        depends_on:
            - "myuaa-mysql"
            - "jhipster-registry"
    myuaa-mysql:
        image: mysql:5.7.20
        environment:
            - MYSQL_USER=root
            - MYSQL_ALLOW_EMPTY_PASSWORD=yes
            - MYSQL_DATABASE=myuaa
        command:             mysqld --lower_case_table_names=1 --skip-ssl
            --character_set_server=utf8mb4 --explicit_defaults_for_timestamp

    jhipster-registry:
        extends:
            file: jhipster-registry.yml
            service: jhipster-registry

app.yml(微服务)

version: '2'
services:
    myservice-app:
        image: myservice
        environment:
            # - _JAVA_OPTIONS=-Xmx512m -Xms256m
            - SPRING_PROFILES_ACTIVE=prod,swagger
            - EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@localhost:8761/eureka
            - SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@localhost:8761/config
            - SPRING_DATASOURCE_URL=jdbc:mysql://myservice-mysql:3306/myservice?useUnicode=true&characterEncoding=utf8&useSSL=false
            - JHIPSTER_SLEEP=10 # gives time for the JHipster Registry to boot before the application
            - JHIPSTER_REGISTRY_PASSWORD=admin
    myservice-mysql:
        extends:
            file: mysql.yml
            service: myservice-mysql
    # jhipster-registry:
    #     extends:
    #         file: jhipster-registry.yml
    #         service: jhipster-registry
    #     environment:
    #         - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=native
    #         - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_LOCATIONS=file:./central-config/docker-config/

0 个答案:

没有答案