美文网首页
Docker compose 使用环境变量

Docker compose 使用环境变量

作者: leeehao | 来源:发表于2018-10-31 14:34 被阅读0次
    version: '2.2'
    
    services:
    
      kong-database:
        image: postgres:9.5-alpine
        container_name: kong-database
        environment:
          - POSTGRES_USER=kong
          - POSTGRES_DB=kong
        healthcheck:
          test: "pg_isready -U kong && psql -d kong -U kong -c \"SELECT 1=1\""
          interval: 10s
          timeout: 5s
          retries: 5
    
      kong-migration:
        image: kong:${KONG_VERSION}
        container_name: kong-migration
        depends_on:
          kong-database:
            condition: service_healthy
        environment:
          - KONG_DATABASE=postgres
          - KONG_PG_HOST=kong-database
        command: sh -c "kong migrations up && touch migrations_run && sleep 30"
        healthcheck:
          test: "if [[ -f migrations_run ]] ; then exit 0; else exit 1; fi"
          interval: 10s
          timeout: 5s
          retries: 5
    
      kong:
        image: kong:${KONG_VERSION}
        container_name: kong
        depends_on:
          kong-migration:
            condition: service_healthy
        healthcheck:
          test: "kong health"
          interval: 10s
          timeout: 5s
          retries: 5
        environment:
          - KONG_DATABASE=postgres
          - KONG_PG_HOST=kong-database
          - KONG_ADMIN_LISTEN=0.0.0.0:8001
        ports:
          - 8001:8001
          - 8000:8000
    
      kong-dashboard:
        build: .
        container_name: kong-dashboard
        ports:
          - 8080:8080
        volumes:
          - .:/app:cached
          - /app/node_modules/
        depends_on:
          kong:
            condition: service_healthy
        entrypoint: ./docker/entrypoint_dev.sh
    

    例如 ${KONG_VERSION} 将会被填充为 KONG_VERSION 的环境变量

    相关文章

      网友评论

          本文标题:Docker compose 使用环境变量

          本文链接:https://www.haomeiwen.com/subject/uohntqtx.html