首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在码头配置中部署spring云配置服务器?

如何在码头配置中部署spring云配置服务器?
EN

Stack Overflow用户
提问于 2019-06-17 15:40:32
回答 1查看 1.6K关注 0票数 1

我的船坞写作有问题。我正在尝试用一个spring云配置服务器来创建多个容器,而我试图在我的webapp容器中使用spring云服务器。

这是我的集装箱清单:

  • 1用于BDD (db)
  • 1用于spring云配置服务器(configproperties)
  • 1用于一些网络应用程序(网络应用程序)
  • 1 nginx用于反向代理(cnginx)

我已经尝试在环境变量中使用localhost (我的配置服务器名)作为主机: SPRING_CLOUD_CONFIG_URI和boostrap.properties。我的“configproperties”容器,在server.xml中使用8085。

那是我的码头

代码语言:javascript
复制
version: '3'
services:
  cnginx:
    image: cnginx
    ports:
      - 80:80
    restart: always
    depends_on:
      - configproperties
      - cprocess
      - webapps
  db:
    image: postgres:9.3
    environment:
      POSTGRES_USER: xxx
      POSTGRES_PASSWORD: xxx
    restart: always
    command:
      - -c
      - max_prepared_transactions=100
  configproperties:
    restart: on-failure:2
    image: configproperties
    depends_on:
      - db
    expose:
      - "8085"
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/mydbName?currentSchema=public
  webapps:
    restart: on-failure:2
    image: webapps
    links:
      - "configproperties"
    environment:
      - SPRING_CLOUD_CONFIG_URI=http://configproperties:8085/config-server
      - SPRING_PROFILES_ACTIVE=docker
    depends_on:
      - configproperties
    expose:
      - "8085"

当我运行我的坞-撰写程序时,我的webapp在部署时会出现一些错误,例如:

  • 无法解析值"${repository.temps}“中的占位符'repository.temps‘

但当我用邮递员发出这样的请求时:

http://localhost/config-server/myApplication/docker/latest --它正常工作,请求返回'myApplication‘的所有配置。

我想我错过了什么,但我找不到.

有人能帮我吗?

致以敬意,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-18 08:58:00

对于使用springcloud服务器,我们只需要在springcloud服务器初始化之后运行我们的webapps。

代码语言:javascript
复制
#!/bin/bash

CONFIG_SERVER_URL=$SPRING_CLOUD_CONFIG_URI/myApp/production/latest

#Check si le le serveur de config est bien lancé
echo 'Waiting for tomcat to be available'
attempt_counter=0
max_attempts=10
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $CONFIG_SERVER_URL)" != "200" ]]; do
    if [ ${attempt_counter} -eq ${max_attempts} ];then
        echo "Max attempts reached on $CONFIG_SERVER_URL"
        exit 1
    fi
    attempt_counter=$(($attempt_counter+1))
    echo "code retour $(curl -s -o /dev/null -w ''%{http_code}'' $CONFIG_SERVER_URL)"
    echo "Attempt to connect to $CONFIG_SERVER_URL : $attempt_counter/$max_attempts"
    sleep 15
done
echo 'Tomcat is available'
mv /usr/local/tomcat/webappsTmp/* /usr/local/tomcat/webapps/
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56634658

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档