简体   繁体   English

如何在 docker-compose 中部署 spring-cloud-config 服务器?

[英]How to deploy spring-cloud-config server in docker-compose?

I've got a problem with my docker-compose.我的 docker-compose 有问题。 I'm trying to create mulitple containers with one spring-cloud-config-server, and im trying to use spring-cloud server with my webapps container.我正在尝试使用一个 spring-cloud-config-server 创建多个容器,并尝试将 spring-cloud 服务器与我的 webapps 容器一起使用。

That's the list of my containers:这是我的容器列表:

  • 1 for the BDD (db) 1 用于 BDD (db)
  • 1 for spring cloud config server (configproperties) 1 用于 spring 云配置服务器(configproperties)
  • 1 for some webapps (webapps) 1 对于一些 webapps (webapps)
  • 1 nginx for reverse proxying (cnginx) 1 用于反向代理的 nginx (cnginx)

I already try to use localhost, my config-server name as host in environment variable : SPRING_CLOUD_CONFIG_URI and in boostrap.properties.我已经尝试使用 localhost,我的配置服务器名称作为环境变量中的主机:SPRING_CLOUD_CONFIG_URI 和 boostrap.properties。 My 'configproperties' container, use 8085 in the server.xml.我的 'configproperties' 容器,在 server.xml 中使用 8085。

That's my docker-compose.yml那是我的 docker-compose.yml

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"

When i run my docker-compose, my webapps are deploying with somme error like:当我运行我的 docker-compose 时,我的 webapps 正在部署一些错误,例如:
- Could not resolve placeholder 'repository.temps' in value "${repository.temps}" - 无法解析值“${repository.temps}”中的占位符“repository.temps”

But when i'm using postman and send a request like that :但是当我使用邮递员并发送这样的请求时:
http://localhost/config-server/myApplication/docker/latest It's working properly, the request return all configuration for 'myApplication'. http://localhost/config-server/myApplication/docker/latest它工作正常,请求返回'myApplication'的所有配置。

I think i have miss somethink, but i don't find it...我想我想念一些东西,但我没有找到它......

Anyone can help me ?任何人都可以帮助我吗?

Regards,问候,

For using springcloud server, we just need to run our webapps after the initialisation of the springcloud server.对于使用 springcloud 服务器,我们只需要在 springcloud 服务器初始化之后运行我们的 webapps。

#!/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/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未找到docker-compose https证书中的spring-cloud-config - spring-cloud-config in docker-compose https certificate not found 在 Docker 中将 Spring-cloud-config 服务器作为微服务托管 - Hosting Spring-cloud-config server as a micro service in Docker Spring docker-compose 和 Kubernetes 之间的云配置行为差异 - Spring Cloud Config behavior difference between docker-compose and Kubernetes 如何使用 docker-compose 将容器部署到谷歌云? - How to deploy container using docker-compose to google cloud? 在客户端重新启动之前,无法使用 docker-compose 访问 Spring Config 服务器 - Spring Config server not reachable with docker-compose until client is restarted 如何在docker-compose 3中使用docker deploy? - How to use docker deploy in docker-compose 3? Docker-compose:在启用spring boot和spring cloud config应用程序时出现问题 - Docker-compose: Issue while running the spring boot enabled and spring cloud config application 如何使用 cloud-init (cloud-config) 启动 docker 容器(或 docker-compose) - How to spin up a docker container (or docker-compose) with cloud-init (cloud-config) 将 Docker 映像部署到使用 docker-compose 运行的谷歌云 - Deploy Docker images to google cloud run with docker-compose docker-compose 中的 Spring 应用程序和 Vault:如何初始化 Vault 服务器? - Spring application and Vault in docker-compose: how to init vault server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM